public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105469] New: "execution reached an unreachable program point" with -flto
@ 2022-05-03 19:58 remi.coulom at gmail dot com
  2022-05-04  6:28 ` [Bug middle-end/105469] " rguenth at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: remi.coulom at gmail dot com @ 2022-05-03 19:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105469
           Summary: "execution reached an unreachable program point" with
                    -flto
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: remi.coulom at gmail dot com
  Target Milestone: ---

Created attachment 52926
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52926&action=edit
compressed preprocessed source file that produces the bug

Operating system and compiler versions:

Ubuntu 20.04: tested with g++ version 7.5.0, 8.4.0, 9.4.0, 10.3.0, 11.1.0, and
13.0 (compiled from git repository this week-end with default options). Also in
32-bit cygwin with 11.2.0. All produce the same problem.

Step to reproduce the problem:

The program works well when compiling without -flto:
$ g++ -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -O3 -fsanitize=unreachable -o repro repro.ii
$ ./repro
-> Yeah, no bug!

adding -flto makes it crash:
$ g++ -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -O3 -flto -fsanitize=unreachable -o repro
repro.ii
$ ./repro
-> repro.cpp:1345:24: runtime error: execution reached an unreachable program
point

I added some trace to the code, that shows a little more information. I tried
to reduce the size of the code as much pas possible, but it was very difficult
because many changes can make the problem appear or disappear. In particular,
not catching exceptions in main makes the bug disappear.

I searched the web for this error message, and found this interesting link:
https://deathandthepenguinblog.wordpress.com/2021/02/13/undefined-behaviour-and-nasal-demons-or-do-not-meddle-in-the-affairs-of-optimizers/
What is described there feels similar to what is happening to me. So I searched
hard for undefined behaviour in my code.

I humbly admit that this crash may very well be a bug in my code instead of a
bug in g++, but after several days of struggle, I still really can make no
sense of what is happening.

If g++ detected undefined behavior in my code and is using this to remove some
part of the code or perform optimizations, then I feel it should tell me. I
want to know, because undefined behavior is much more likely to be a bug that
needs fixing rather than a good optimization opportunity.

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

end of thread, other threads:[~2023-07-07 10:43 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-03 19:58 [Bug c++/105469] New: "execution reached an unreachable program point" with -flto remi.coulom at gmail dot com
2022-05-04  6:28 ` [Bug middle-end/105469] " rguenth at gcc dot gnu.org
2022-05-04  7:15 ` remi.coulom at gmail dot com
2022-05-04  8:54 ` marxin at gcc dot gnu.org
2022-05-04  9:28 ` jakub at gcc dot gnu.org
2022-05-04 10:30 ` marxin at gcc dot gnu.org
2022-05-04 10:33 ` marxin at gcc dot gnu.org
2022-05-04 10:34 ` marxin at gcc dot gnu.org
2022-05-04 10:44 ` rguenth at gcc dot gnu.org
2022-05-04 10:50 ` marxin at gcc dot gnu.org
2022-05-04 10:53 ` marxin at gcc dot gnu.org
2022-05-04 11:01 ` [Bug middle-end/105469] "execution reached an unreachable program point" with -flto since r5-7027-g0b986c6ac777aa4e marxin at gcc dot gnu.org
2022-05-04 11:01 ` jakub at gcc dot gnu.org
2022-05-05  4:50 ` pinskia at gcc dot gnu.org
2022-05-11 12:47 ` remi.coulom at gmail dot com
2022-09-14 13:08 ` [Bug middle-end/105469] [10/11/12/13 Regression] " rguenth at gcc dot gnu.org
2023-01-18 16:46 ` jakub at gcc dot gnu.org
2023-01-18 16:47 ` jakub at gcc dot gnu.org
2023-01-18 21:30 ` hubicka at gcc dot gnu.org
2023-01-19 13:25 ` jamborm at gcc dot gnu.org
2023-07-07 10:43 ` [Bug middle-end/105469] [11/12/13/14 " rguenth 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).