TDPL book and __traits(compiles...) snippet
Tony
tonytdominguez at aol.com
Sun Jul 11 03:30:07 UTC 2021
In section 6.2 of The D Programming Language it talks about how
the compiler will try and tell if you are going to use a null
reference. It gives this code snippet below to demonstrate that.
But with DMD v2.096.1-dirty I am getting that the compiler thinks
the code is OK. With a "!" the assert fails.
class A { int x; }
A a;
assert(!__traits(compiles, a.x = 5));
More information about the Digitalmars-d-learn
mailing list