[Bug c++/94768] Wreturn-type should be error, not warning

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Apr 26 07:29:40 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94768

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Binderman from comment #0)
> IMHO, for a C++ function returning non-void, a complete absence of any
> return statement in the function really should produce an error.

This is a valid C++ program and it would be non-conforming to reject it. The
compiler can't even assume the program has undefined behaviour, because g(int)
could throw an exception, or do something that terminates, or simply never
return (e.g. go into an infinite loops with side effects like I/O).


More information about the Gcc-bugs mailing list