Re: Bug#119440: g++: Compiler does not give any errors when a function fails to return required value
> Are there any warnings that are enabled by default?
Yes. For example, compiling
void x(){
short y = 0xFFFF0000;
}
gives the warning
warning: overflow in implicit constant conversion
However, this is different from the -Wreturn-type warning: The
compiler has reliable algorithm that guarantees that the warning is
only issued whenever the program has undefined behaviour (as it does
when converting a large integer constant to short).
A similar algorithm does not exist for reliably determining that a
function falls off its end.
Regards,
Martin
Reply to: