int* casted to IntPtr shows as error

As the subject says, the following code:

int* pi = &123;
IntPtr ptr = (IntPtr)pi;

is highlighted by ReSharper - "Cannot cast expression of type int* to type
IntPtr". While this is technically correct, there is an implicit conversion
from any pointer type to void*, and thus an indirect (and legal) conversion
from int* to IntPtr. I suspect this may be a general case of ReSharper
missing valid implicit conversions.

Thanks,

Jim

ThoughtWorks


1 comment
Comment actions Permalink

Jim,

thanks for your report. I've added a request to the tracker:

http://www.intellij.net/tracker/resharper/viewSCR?publicId=1983

"Jim Arnold" <buffportion@btinternet.com> wrote in message
news:c66pr5$v87$1@is.intellij.net...

As the subject says, the following code:

>

int* pi = &123;
IntPtr ptr = (IntPtr)pi;

>

is highlighted by ReSharper - "Cannot cast expression of type int* to type
IntPtr". While this is technically correct, there is an implicit

conversion

from any pointer type to void*, and thus an indirect (and legal)

conversion

from int* to IntPtr. I suspect this may be a general case of ReSharper
missing valid implicit conversions.

>

Thanks,

>

Jim

>

ThoughtWorks

>
>


0

Please sign in to leave a comment.