June 20, 2013 Re: debug & optimization | ||||
---|---|---|---|---|
| ||||
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.
|
June 20, 2013 Re: debug & optimization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Justin Whear | 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.
|
Copyright © 1999-2021 by the D Language Foundation