* [Bug c++/94768] Wreturn-type should be error, not warning
2020-04-26 7:09 [Bug c++/94768] New: Wreturn-type should be error, not warning dcb314 at hotmail dot com
@ 2020-04-26 7:29 ` redi at gcc dot gnu.org
2020-04-26 7:33 ` redi at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-26 7:29 UTC (permalink / raw)
To: gcc-bugs
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).
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/94768] Wreturn-type should be error, not warning
2020-04-26 7:09 [Bug c++/94768] New: Wreturn-type should be error, not warning dcb314 at hotmail dot com
2020-04-26 7:29 ` [Bug c++/94768] " redi at gcc dot gnu.org
@ 2020-04-26 7:33 ` redi at gcc dot gnu.org
2020-04-26 7:47 ` dcb314 at hotmail dot com
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-26 7:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94768
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> This is a valid C++ program
s/program/translation unit/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/94768] Wreturn-type should be error, not warning
2020-04-26 7:09 [Bug c++/94768] New: Wreturn-type should be error, not warning dcb314 at hotmail dot com
2020-04-26 7:29 ` [Bug c++/94768] " redi at gcc dot gnu.org
2020-04-26 7:33 ` redi at gcc dot gnu.org
@ 2020-04-26 7:47 ` dcb314 at hotmail dot com
2020-04-26 8:32 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: dcb314 at hotmail dot com @ 2020-04-26 7:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94768
--- Comment #3 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> This is a valid C++ program and it would be non-conforming to reject it.
Surprising. The standard looks broken to me. Standards conformance
only really matters if GNU C++ is in standards conformance mode.
Most of the time, it is in its own GNU mode and so could do a more
useful job here rather than IMHO blindly following non-useful standards.
I checked the source code of the popular Fedora Linux distribution.
There are 32 examples of this problem in the C++ code, so they will
need fixing.
Interestingly, there are a whopping 258 examples in the C code, but that's a
separate issue.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/94768] Wreturn-type should be error, not warning
2020-04-26 7:09 [Bug c++/94768] New: Wreturn-type should be error, not warning dcb314 at hotmail dot com
` (2 preceding siblings ...)
2020-04-26 7:47 ` dcb314 at hotmail dot com
@ 2020-04-26 8:32 ` pinskia at gcc dot gnu.org
2020-04-26 8:33 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-04-26 8:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94768
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> (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).
Just to expand on this. undefined at runtime behavior is not supposed to stop
compilation of a translation unit.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/94768] Wreturn-type should be error, not warning
2020-04-26 7:09 [Bug c++/94768] New: Wreturn-type should be error, not warning dcb314 at hotmail dot com
` (3 preceding siblings ...)
2020-04-26 8:32 ` pinskia at gcc dot gnu.org
@ 2020-04-26 8:33 ` pinskia at gcc dot gnu.org
2020-04-26 9:39 ` redi at gcc dot gnu.org
2020-04-26 9:44 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-04-26 8:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94768
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to David Binderman from comment #3)
> I checked the source code of the popular Fedora Linux distribution.
> There are 32 examples of this problem in the C++ code, so they will
> need fixing.
>
> Interestingly, there are a whopping 258 examples in the C code, but that's a
> separate issue.
Note C and C++ have slightly different notice about "no return statement in
function returning non-void"; In C it is only undefined if the return value is
used while in C++ it is undefined the moment that the end of the function
happens.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/94768] Wreturn-type should be error, not warning
2020-04-26 7:09 [Bug c++/94768] New: Wreturn-type should be error, not warning dcb314 at hotmail dot com
` (4 preceding siblings ...)
2020-04-26 8:33 ` pinskia at gcc dot gnu.org
@ 2020-04-26 9:39 ` redi at gcc dot gnu.org
2020-04-26 9:44 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-26 9:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94768
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Binderman from comment #3)
> Most of the time, it is in its own GNU mode and so could do a more
> useful job here rather than IMHO blindly following non-useful standards.
Nobody is "blindly following" anything. It's been discussed in detail by people
who know what they're talking about, over many years (including again when
-Wreturn-type was enabled by default for C++). Rejecting valid C++ code by
default is not OK.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/94768] Wreturn-type should be error, not warning
2020-04-26 7:09 [Bug c++/94768] New: Wreturn-type should be error, not warning dcb314 at hotmail dot com
` (5 preceding siblings ...)
2020-04-26 9:39 ` redi at gcc dot gnu.org
@ 2020-04-26 9:44 ` redi at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2020-04-26 9:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94768
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=55189
Resolution|INVALID |DUPLICATE
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Dup of PR 43943 (and others)
*** This bug has been marked as a duplicate of bug 43943 ***
^ permalink raw reply [flat|nested] 8+ messages in thread