Should we warn if we detect null derefernces or void value uses ?

burjui via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 6 22:47:56 PST 2016


On Monday, 5 December 2016 at 04:41:55 UTC, Stefan Koch wrote:
> Hi Guys,
> What is your opinion, should we warn if we unambiguously detect 
> something that is clearly unwanted ?
>
> int fn(int y)
> {
>   int x = void;
>   ++x;
>   return x+y;
> }
>
>  This requires data-flow analysis (The same kind that tells you 
> if you are skipping a statement)
> And will slow down compilation a little if we enable such a 
> warning.

Yes, but we should issue an error, like Andrei said. A language 
is only as useful as it's best implementation, so diagnostics 
like that are essential. Data-flow analysis shouldn't even be 
optional or lacking in any modern compiler.


More information about the Digitalmars-d mailing list