Search code examples
pvs-studio

V3125 false positive when having empty statement after return


This minimal example triggers V3125 about member being used after it was verified against null. If I remove the extra semicolon after the first return statement V3125 is no longer triggered.

public class PVS_nullcheck
{
    private object member;

    public int Method()
    {
        if (member == null)
        {
            return 0;
            ; // <-- 3125
        }

        return member.GetHashCode();
    }
}

Solution

  • Thank you for the feedback. We have fixed this false alarm, the fix will be available in the next release version of PVS-Studio. You can download the latest beta from here.