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);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With