Should we warn if we detect null derefernces or void value uses ?
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Wed Dec 7 04:42:51 PST 2016
On 12/7/2016 3:52 AM, Stefan Koch wrote:
> That is why I said unambiguously.
Ok.
> We will neither warn or error in the above case, because p could have been
> assigned to.
> Only if we directly read from something uninitialized will we error.
The dmd optimizer does global data flow analysis:
int fn(int y)
{
int x = void;
++x;
return x+y;
}
----
dmd -c test7 -O
test7.d(4): Error: variable x used before set
----
https://github.com/dlang/dmd/blob/master/src/backend/gother.c#L418
dmd's back end has done global data flow analysis since about 1985, even though
popular opinion holds that clang invented it :-)
More information about the Digitalmars-d
mailing list