Thanks ---------------- enum State { ONE, TWO } struct TestA { private State *state; void method(ref State program_state) { this.state = &program_state; } this (int temp_arg) { import std.stdio; // Problem code if (*this.state == state.ONE) "ONE".writeln; } } void main() { State program_state = State.TWO; auto a = TestA(1); a.method(program_state); }
Can the compiler catch my stupid mistake?
Jack Stouffer via Digitalmars-d Fri, 14 Aug 2015 10:41:48 -0700
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.
- Can the compiler catch my stupid mi... Jack Stouffer via Digitalmars-d
- Re: Can the compiler catch my ... Steven Schveighoffer via Digitalmars-d
- Re: Can the compiler catch... Jack Stouffer via Digitalmars-d
- Re: Can the compiler c... Meta via Digitalmars-d
- Re: Can the compil... Jack Stouffer via Digitalmars-d
- Re: Can the c... Temtaime via Digitalmars-d
- Re: Can the c... deadalnix via Digitalmars-d
- Re: Can the c... Steven Schveighoffer via Digitalmars-d
- Re: Can the compiler catch my ... Jack Stouffer via Digitalmars-d
- Re: Can the compiler catch... Jack Stouffer via Digitalmars-d