Skip to content

false positive redundant cast #32773

@MkazemAkhgary

Description

@MkazemAkhgary

Assuming that bounds is long, start and end is int. following gives a warning

Bitwise-or operator used on a sign-extended operand; consider casting to a smaller unsigned type first

bounds = (((long)end) << 32) | start;

In my case it doesn't really matter to use sign or zero extension. start is always positive. for sake of hiding the warning

bounds = (((long)end) << 32) | ((long)start);

says cast is redundant. I think if compiler suggests to resolve ambiguity, then it shouldn't suggest to introduce ambiguity again. (in my case it doesn't matter but i thought its good to share)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBugIDE-CodeStyleBuilt-in analyzers, fixes, and refactoringshelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions