Thread overview | |||||
---|---|---|---|---|---|
|
November 23, 2005 assert bug | ||||
---|---|---|---|---|
| ||||
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.
|
November 23, 2005 Re: assert bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tiago Gasiba | 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;
> }
>
> Tiago
>
Nothing 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.
|
November 23, 2005 Re: assert bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to zwang | zwang schrieb: > 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; >> } >> >> Tiago >> > > Nothing 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. 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. |
Copyright © 1999-2021 by the D Language Foundation