public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/87515] "no return statement in function returning non-void" miscompiles with optimizations
       [not found] <bug-87515-4@http.gcc.gnu.org/bugzilla/>
@ 2020-06-13 11:32 ` ipelupes at hotmail dot com
  2020-06-13 11:51 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: ipelupes at hotmail dot com @ 2020-06-13 11:32 UTC (permalink / raw)
  To: gcc-bugs

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

ipelupes <ipelupes at hotmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ipelupes at hotmail dot com

--- Comment #4 from ipelupes <ipelupes at hotmail dot com> ---
I think the warning is not enough, because the resulting behaviour is quite
hard to debug, affecting the program flow, eg the following:

include <stdio.h>

int f()
{
}

int main()
{
  printf("calling returnless nonvoid\n");
  f();
  return 0;
}

compiled with g++  -O2 test.C

prints out "calling returnless nonvoid" for a few thousand times before seg
faulting on my machine (gcc 9.3.1). I would not be helped by the warning in
tracking this down in a large project (often lots of warnings are present).

also: adding __builtin_unreachable(); hides the warning making it even harder
to find

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/87515] "no return statement in function returning non-void" miscompiles with optimizations
       [not found] <bug-87515-4@http.gcc.gnu.org/bugzilla/>
  2020-06-13 11:32 ` [Bug c++/87515] "no return statement in function returning non-void" miscompiles with optimizations ipelupes at hotmail dot com
@ 2020-06-13 11:51 ` jakub at gcc dot gnu.org
  2020-06-15 10:29 ` redi at gcc dot gnu.org
  2023-06-27 17:51 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-06-13 11:51 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
You can always use -Werror=return-type, or -fsanitize=undefined which will
diagnose it at runtime.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/87515] "no return statement in function returning non-void" miscompiles with optimizations
       [not found] <bug-87515-4@http.gcc.gnu.org/bugzilla/>
  2020-06-13 11:32 ` [Bug c++/87515] "no return statement in function returning non-void" miscompiles with optimizations ipelupes at hotmail dot com
  2020-06-13 11:51 ` jakub at gcc dot gnu.org
@ 2020-06-15 10:29 ` redi at gcc dot gnu.org
  2023-06-27 17:51 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-15 10:29 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/87515] "no return statement in function returning non-void" miscompiles with optimizations
       [not found] <bug-87515-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-06-15 10:29 ` redi at gcc dot gnu.org
@ 2023-06-27 17:51 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-06-27 17:51 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |DUPLICATE

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
.

*** This bug has been marked as a duplicate of bug 86761 ***

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-27 17:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-87515-4@http.gcc.gnu.org/bugzilla/>
2020-06-13 11:32 ` [Bug c++/87515] "no return statement in function returning non-void" miscompiles with optimizations ipelupes at hotmail dot com
2020-06-13 11:51 ` jakub at gcc dot gnu.org
2020-06-15 10:29 ` redi at gcc dot gnu.org
2023-06-27 17:51 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).