Definitive list of storage classes

ag0aep6g anonymous at example.com
Sat Jan 30 07:31:11 UTC 2021


On 30.01.21 02:46, MoonlightSentinel wrote:
> The problem is that dmd treats const/immutable variables kinda like 
> enums when they have an initializer. The final AST never accesses x, y 
> but uses their initializers instead:

Throw `__ctfe` into the mix and it gets even more fun:

void main()
{
     const bool x = __ctfe;
     version (none) static const bool y = __ctfe; /* Error: variable 
`__ctfe` cannot be read at compile time */
     else static const bool y = x; /* no error */
     static assert(x == y); /* passes */
     assert(x == y); /* fails */
}


More information about the Digitalmars-d mailing list