Warning: statement is not reachable

Tamas via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 1 13:30:44 PST 2016


My d code doesn't compile using ldc2 1.0.0-alpha or anything 
above DMD v2.068.0

Using these compilers I get a lot of "Warning: statement is not 
reachable". Then the both compiler crashes.

I minimized the code to get the same warning, although the 
compilers do not crash this time, so this might not be the real 
culprit.

Any suggestion how to fix this?
Thanks!

ldc2 -w reach.d
dmd -w reach.d

reach.d:

     struct Tag {}

     template isTagged(S) {
       enum bool isTagged =
         delegate() {
           foreach(attr; __traits(getAttributes, S)) {
             static if (is(attr == Tag)) {
               return true;
             }
           }
           return false;
         }();
     }

     void main() {
       static @Tag struct MyStruct {}
       static struct VanillaStruct {}
       static assert(isTagged!MyStruct);
       static assert(!isTagged!VanillaStruct);
     }


More information about the Digitalmars-d-learn mailing list