V3125 False Positive

61 Views Asked by At

PVS Studio throws V3125: The 'control.Parent' object was used after it was verified against null. Check lines: 11, 9.

using System.Windows.Forms;

namespace V3125_False_Positive
{
    static class Program
    {
        static void Main()
        {
            if (new Control() is Control control && control.Parent != null)
            {
                string parentname = control.Parent.Name;
            }
        }
    }
}

Is this a false positive?

1

There are 1 best solutions below

0
On

Indeed, this is a false positive. We'll look into it and try fixing it for the next release (actually, for the release after the next one, as we are planning to release a new version in about a week, so the fix will not make it).

Thanks for the tip!