immutable int n = Test(); int[n] x;---- compiles, but __ctfe is false. How?

FreeSlave freeslave93 at gmail.com
Fri Feb 21 06:04:44 PST 2014


Another strange thing:

import std.stdio;

uint Test()
{
     if (!__ctfe)
     {
         return 3;
     }
     return 2;
}



void main()
{
     immutable n = Test();
     int[n] arr;
     writeln("arrary length = ", arr.length, " ; n = ", n);
}

Output:
arrary length = 2 ; n = 3

When you think about it you understand that it's logically right 
behavior, but it's not acceptable in practice.


More information about the Digitalmars-d-learn mailing list