Structures and CTFE

agorkvmh forengj at gmail.com
Mon Sep 3 13:39:25 UTC 2018


Hi all,

Running this:
---
static assert(Foo(1).pos == 2);


struct Foo
{
     this(int i){ advance(); }

     size_t pos =1;

     void advance()
     {
         pragma(msg, pos);
         pos = pos+1;
         pragma(msg, pos);
     }
}

dmd -o- -unittest source/pgs/parser.d
1LU
1LU
---

The static assert passes, but why the second pragma print '1'?

Thanks



More information about the Digitalmars-d-learn mailing list