Can the compiler catch my stupid mistake?

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 14 10:44:11 PDT 2015


On 8/14/15 1:36 PM, Jack Stouffer wrote:
> Recently, I made the mistake of trying to reference an enum pointer in a
> struct before it was set (see example below). I was wondering if it's
> possible for DMD to catch this mistake at compile time, as this
> currently compiles fine and segfaults on execution.

state *is* set to null, before your constructor is called. The access is 
not "before it was set".

Could the compiler *possibly* flag this as an error? It could, but it 
doesn't, and likely won't in the future.

-Steve


More information about the Digitalmars-d mailing list