digitalmars.D.learn - debug & optimization
- Charles Hixson (13/13) Jun 18 2013 Would:
- Justin Whear (6/19) Jun 20 2013 A debug block works just like any other version(...) block: if the
- Justin Whear (3/24) Jun 20 2013 Ah my bad, I didn't realize you were asking about the function containin...
- bearophile (6/10) Jun 20 2013 At a low optimization level probably dmd keeps the call to the
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 -- Charles Hixson
Jun 18 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 callA 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.
Jun 20 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:Ah my bad, I didn't realize you were asking about the function containing the block.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 callA 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.
Jun 20 2013
Charles Hixson: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 callAt a low optimization level probably dmd keeps the call to the empty function. At a high optimization level the call probably is optimized away. Bye, bearophile
Jun 20 2013