Mic*_* J. 5 c# static-analysis nullable coverity
No doubt there are other, perhaps better ways to do this, but I'm trying to understand what is going on here.
In the below example, coverity is reporting a FORWARD_NULL defect on the fourth line.
double? foo = null;
double bar = 1.23;
foo += bar;
System.Windows.Point point = new System.Windows.Point(foo,bar);
Run Code Online (Sandbox Code Playgroud)
it reports:
assign_zero: Assigning: foo = null.
on the foo += bar line.
in += Operator (C# Reference), I see that x += y is equivalent to x = x + y, and in Using nullable types (C+ Programming Guide), I see that
These operators [the binary operator] produce a null value if one or both operands are null
so is that what is going on? foo += bar becomes foo = foo + bar and since foo is null, foo + bar is null?
so is that what is going on? foo += bar becomes foo = foo + bar and since foo is null, foo + bar is null?
Yes.