[Bug c++/87515] "no return statement in function returning non-void" miscompiles with optimizations
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jun 15 10:29:31 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87515
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to ipelupes from comment #4)
> also: adding __builtin_unreachable(); hides the warning making it even
> harder to find
Don't do that then :)
Adding that promises the compiler your program will never reach that line of
the function, so it doesn't bother warning you. If you lie to the compiler, it
will get its revenge.
Adding __builtin_trap() instead will terminate the program if that line is
reached, which might be what you're looking for.
More information about the Gcc-bugs
mailing list