version(assert) and Phobos release unittest build

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Nov 28 09:15:57 PST 2013


On 28/11/13 17:59, Dicebot wrote:
> version(assert) is negated by -unittest at all actually:
>
> import std.stdio;
>
> void main()
> {
>      version ( assert )
>      {
>          writeln("errr");
>      }
> }
>
> $ rdmd -release test.d
> $ rdmd -release -unittest test.d
> errr
>
> That is so bad >_<

Aaaaaack!! :-\

And to add to the confusion and inconsistency, it _does_ still strip in- and 
out-contracts of functions -- see e.g.:

     import std.stdio;

     void foo(int i)
     in
     {
         writeln("In contract enabled.");
     }
     out
     {
         writeln("Out contract enabled.");
     }
     body
     {
         writeln("This is the body of foo.");
     }

     void main()
     {
         foo(4);
     }

which will output all 3 messages in normal mode, but only the "body" one when 
compiled with -release.

This is the reason for my original help request -- an in-contract was triggering 
an AssertError in regular unittests, but not in release-mode unittests.


More information about the Digitalmars-d-learn mailing list