B
brian tyler
I have written quite a lot of code over the past few months and
(stupidly) have only compiled it with debug flags (-g) during the
development process. As such it turns out that I have written things
like:
int my_function( void ) {
int( 1 );
}
when I have meant to write
int my_function( void ) {
return int( 1 );
}
gcc (4.1.2) seems to assume the return with debug flags on, but does
not when optimising (-O1). In both cases the function compiles,
however when debugging "int( 1 );" is returned (what I expect the
behaviour to be) and when optimising "int()" is returned (not what I
expect to happen).
The fact that it compiles makes it a total pain to find where the
error is. I know that the microsoft compiler strictly enforces a
return value when one is given, is there a way to make gcc behave in
the same way, ie so that the fist function will fail to compile.
Thanks,
Brian.
(stupidly) have only compiled it with debug flags (-g) during the
development process. As such it turns out that I have written things
like:
int my_function( void ) {
int( 1 );
}
when I have meant to write
int my_function( void ) {
return int( 1 );
}
gcc (4.1.2) seems to assume the return with debug flags on, but does
not when optimising (-O1). In both cases the function compiles,
however when debugging "int( 1 );" is returned (what I expect the
behaviour to be) and when optimising "int()" is returned (not what I
expect to happen).
The fact that it compiles makes it a total pain to find where the
error is. I know that the microsoft compiler strictly enforces a
return value when one is given, is there a way to make gcc behave in
the same way, ie so that the fist function will fail to compile.
Thanks,
Brian.