digitalmars.D.bugs - assert bug
- Tiago Gasiba (14/14) Nov 23 2005 The following code compiles OK but behaves differently if you change the...
- zwang (4/21) Nov 23 2005 Nothing wrong here.
- Tiago Gasiba (8/31) Nov 23 2005 True. Shame on me :)
The following code compiles OK but behaves differently if you change the function return value from double to void: double f( double p ){ //void f( double p ){ assert( p>0.0 ); } int main( ){ double p = 10.01; f( p ); return 0; } Tiago -- Tiago Gasiba (M.Sc.) - http://www.gasiba.de Everything should be made as simple as possible, but not simpler.
Nov 23 2005
Tiago Gasiba wrote:The following code compiles OK but behaves differently if you change the function return value from double to void: double f( double p ){ //void f( double p ){ assert( p>0.0 ); } int main( ){ double p = 10.01; f( p ); return 0; } TiagoNothing wrong here. When the return type is not void, and your function doesn't return a value, dmd inserts an "assert(0);" at the end of the function.
Nov 23 2005
zwang schrieb:Tiago Gasiba wrote:True. Shame on me :) I have found a bug on assert, though, that crashes with SIGSEGV. I'll try to reproduce it again and then post it. Tiago -- Tiago Gasiba (M.Sc.) - http://www.gasiba.de Everything should be made as simple as possible, but not simpler.The following code compiles OK but behaves differently if you change the function return value from double to void: double f( double p ){ //void f( double p ){ assert( p>0.0 ); } int main( ){ double p = 10.01; f( p ); return 0; } TiagoNothing wrong here. When the return type is not void, and your function doesn't return a value, dmd inserts an "assert(0);" at the end of the function.
Nov 23 2005