Skip to content

IDE0004 'Unnecessary cast' suggestion breaks code #41433

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


unsafe int Test(IntPtr safePointer)
{
    // Suggests to remove the "int*" cast.
    return ((int*)safePointer)[0];
}

unsafe int Test(IntPtr safePointer)
{
    // Error after using suggestion.
    return safePointer[0];
}

IntPtr cannot even be indexed, so this suggestion really breaks code.


Original Comments

Visual Studio Feedback System on 2/3/2020, 04:23 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.


Original Solutions

(no solutions)

Metadata

Metadata

Labels

Area-IDEBugDeveloper CommunityThe issue was originally reported on https://developercommunity.visualstudio.comResolution-FixedThe bug has been fixed and/or the requested behavior has been implemented

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions