opAssign() still accepted for classes???
KennyTM~
kennytm at gmail.com
Fri Apr 29 10:03:05 PDT 2011
On Apr 30, 11 00:14, Alexander wrote:
> On 29.04.2011 17:05, Steven Schveighoffer wrote:
>
>> x = y is equivalent to x.opAssign(y). So x is null, you are dereferencing a null pointer.
>
> Second thought... Since compiler *knows* that the pointer is null at this point, shouldn't it produce a warning at least?
>
> /Alexander
That requires data flow analysis. For example, how could the compiler
knows the 'x' below is 'null'?
K x;
if (veryComplexCondition(y))
x = new K;
x = 4.0; // <----
See http://www.digitalmars.com/d/2.0/faq.html#nan.
(That said, I see no problem treating this as a warning (which is
outside of the D spec) if a variable is provable 'null'.)
More information about the Digitalmars-d
mailing list