version(assert) defined variables

Shachar Shemesh via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 30 04:07:41 PST 2014


Hi all,

Please consider the following program:
int main()
{
     version(assert) int var;

     assert(var == 0);

     return 0;
}

When compiled with "dmd test.d", it passes without a problem. When 
compiled with "dmd test.d -release", it produces the following error:
test.d(5): Error: undefined identifier var

This makes no sense. In order to make the program compile, I need to do 
the (quite nonsensical):

version(assert) assert(var == 0);

Is this on purpose?

Shachar


More information about the Digitalmars-d mailing list