debug & optimization

Justin Whear justin at economicmodeling.com
Thu Jun 20 16:33:03 PDT 2013


On Thu, 20 Jun 2013 22:56:08 +0000, Justin Whear wrote:

> 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.

Ah my bad, I didn't realize you were asking about the function containing 
the block.


More information about the Digitalmars-d-learn mailing list