www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Bad use of assert in sample winsamp.d

The code of winsamp.d includes this line:


Although at the moment it seems that the assert body is evaluated 
whether -release is specified or not, this will not be the case in 
general.  As said, and quite sensibly, "The compiler may optionally not 
evaluate assert expressions at all."  When the compiler is improved so 
that assert expressions aren't evaluated in release mode, the class 
won't be registered at all, and so the program will not work.

The statement should therefore be replaced by

     if (!RegisterClassA(&wc)) assert(false);

or perhaps better

     if (!RegisterClassA(&wc)) throw new Error("RegisterClass failed!");

Nov 15 2004