debug & optimization

Justin Whear justin at economicmodeling.com
Thu Jun 20 15:56:08 PDT 2013


On Tue, 18 Jun 2013 12:39:31 -0700, Charles Hixson wrote:

> Would:
> void    test(string s = "default message")
> { debug
>    {
>        .........
>    } // debug
> } // test
> 
> be optimized away in code that was compiled with debug turned off?
> 
> I've documented my code that this is a noop unless debug is true, but
> I'm not really sure that's correct, or whether there would be a function
> call

A debug block works just like any other version(...) block: if the 
version is not set, the compiler ignores the block completely.  The 
contents of the block are parsed (must be syntactically valid) but no 
semantic analysis or code-gen is performed on it, so unless the version 
is set, it's as if the contents of the block never existed.


More information about the Digitalmars-d-learn mailing list