public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address
@ 2022-06-09 17:16 k.even-mendoza at imperial dot ac.uk
  2022-06-09 17:24 ` [Bug middle-end/105910] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: k.even-mendoza at imperial dot ac.uk @ 2022-06-09 17:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105910
           Summary: ICE: with -O1 optimization level and code calling
                    __builtin_return_address
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: k.even-mendoza at imperial dot ac.uk
  Target Milestone: ---

This code (reduced): 
===
int a;
void b() {
  a = ((long)__builtin_return_address(0) ^ (long)__builtin_return_address(0)) *
      (long)__builtin_return_address(524288);
}
int main(void) { return 0;}
===
crashed the compiler with -O1: gcc -O1 test4.c

gcc: internal compiler error: Segmentation fault signal terminated program cc1
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See <https://gcc.gnu.org/bugs/> for instructions.

====
It works fine with other optimization levels including -O0. It happens with
gcc-11, gcc-12 and gcc-13 (tested with 20220606); with gcc-10 and below it
seems to work fine also with -O1.

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

* [Bug middle-end/105910] ICE: with -O1 optimization level and code calling __builtin_return_address
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
@ 2022-06-09 17:24 ` pinskia at gcc dot gnu.org
  2022-06-09 17:31 ` k.even-mendoza at imperial dot ac.uk
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-09 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I am sure 524288 value will cause a runtime undefined and even a crash at
runtime .

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

* [Bug middle-end/105910] ICE: with -O1 optimization level and code calling __builtin_return_address
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
  2022-06-09 17:24 ` [Bug middle-end/105910] " pinskia at gcc dot gnu.org
@ 2022-06-09 17:31 ` k.even-mendoza at imperial dot ac.uk
  2022-06-21  5:39 ` [Bug rtl-optimization/105910] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: k.even-mendoza at imperial dot ac.uk @ 2022-06-09 17:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Karine EM <k.even-mendoza at imperial dot ac.uk> ---
It is probably the case: gcc-10 just compiles the program (as it is a UB) which
crashes with "Abort" when trying to actually run this program; llvm returns an
error: 
test4.c:4:13: error: argument value 524288 is outside the valid range [0,
65535]

I think instead of an ICE, any of the options is a good solution.

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

* [Bug rtl-optimization/105910] ICE: with -O1 optimization level and code calling __builtin_return_address
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
  2022-06-09 17:24 ` [Bug middle-end/105910] " pinskia at gcc dot gnu.org
  2022-06-09 17:31 ` k.even-mendoza at imperial dot ac.uk
@ 2022-06-21  5:39 ` pinskia at gcc dot gnu.org
  2023-05-17 23:36 ` [Bug middle-end/105910] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-21  5:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|middle-end                  |rtl-optimization

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

#4  0x0000000001c30dc5 in distribute_notes(rtx_def*, rtx_insn*, rtx_insn*,
rtx_insn*, rtx_def*, rtx_def*, rtx_def*) () at
/home/apinski/src/upstream-gcc/gcc/gcc/combine.cc:14535
#5  0x0000000001c30dc5 in distribute_notes(rtx_def*, rtx_insn*, rtx_insn*,
rtx_insn*, rtx_def*, rtx_def*, rtx_def*) () at
/home/apinski/src/upstream-gcc/gcc/gcc/combine.cc:14535
.....

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

* [Bug middle-end/105910] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
                   ` (2 preceding siblings ...)
  2022-06-21  5:39 ` [Bug rtl-optimization/105910] " pinskia at gcc dot gnu.org
@ 2023-05-17 23:36 ` pinskia at gcc dot gnu.org
  2023-05-17 23:36 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-17 23:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |4.1.2
            Summary|ICE: with -O1 optimization  |__builtin_return_address
                   |level and code calling      |expansion with a large #
                   |__builtin_return_address    |causes a compile time
                   |                            |issues and even ICEs
                   |                            |sometimes
          Component|rtl-optimization            |middle-end

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Instead of producing 524288 instructions, I suspect we could expand that as a
loop and such.

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

* [Bug middle-end/105910] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
                   ` (3 preceding siblings ...)
  2023-05-17 23:36 ` [Bug middle-end/105910] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes pinskia at gcc dot gnu.org
@ 2023-05-17 23:36 ` pinskia at gcc dot gnu.org
  2023-05-17 23:39 ` [Bug middle-end/105910] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-17 23:36 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-05-17
             Status|UNCONFIRMED                 |NEW

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

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

* [Bug middle-end/105910] [11/12/13/14 Regression] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
                   ` (4 preceding siblings ...)
  2023-05-17 23:36 ` pinskia at gcc dot gnu.org
@ 2023-05-17 23:39 ` pinskia at gcc dot gnu.org
  2023-07-19 11:03 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-17 23:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |10.1.0, 4.7.2, 9.5.0
           Keywords|                            |needs-bisection
            Summary|__builtin_return_address    |[11/12/13/14 Regression]
                   |expansion with a large #    |__builtin_return_address
                   |causes a compile time       |expansion with a large #
                   |issues and even ICEs        |causes a compile time
                   |sometimes                   |issues and even ICEs
                   |                            |sometimes
      Known to fail|                            |11.1.0

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Hmm, this used to work with GCC 10.1.0 and before.

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

* [Bug middle-end/105910] [11/12/13/14 Regression] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
                   ` (5 preceding siblings ...)
  2023-05-17 23:39 ` [Bug middle-end/105910] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-07-19 11:03 ` rguenth at gcc dot gnu.org
  2023-10-16 14:00 ` pinskia at gcc dot gnu.org
  2024-04-11  2:24 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-19 11:03 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.5

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

* [Bug middle-end/105910] [11/12/13/14 Regression] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
                   ` (6 preceding siblings ...)
  2023-07-19 11:03 ` rguenth at gcc dot gnu.org
@ 2023-10-16 14:00 ` pinskia at gcc dot gnu.org
  2024-04-11  2:24 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-10-16 14:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |141242068 at smail dot nju.edu.cn

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 111834 has been marked as a duplicate of this bug. ***

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

* [Bug middle-end/105910] [11/12/13/14 Regression] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes
  2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
                   ` (7 preceding siblings ...)
  2023-10-16 14:00 ` pinskia at gcc dot gnu.org
@ 2024-04-11  2:24 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-11  2:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #8 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup really.

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

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

end of thread, other threads:[~2024-04-11  2:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 17:16 [Bug c/105910] New: ICE: with -O1 optimization level and code calling __builtin_return_address k.even-mendoza at imperial dot ac.uk
2022-06-09 17:24 ` [Bug middle-end/105910] " pinskia at gcc dot gnu.org
2022-06-09 17:31 ` k.even-mendoza at imperial dot ac.uk
2022-06-21  5:39 ` [Bug rtl-optimization/105910] " pinskia at gcc dot gnu.org
2023-05-17 23:36 ` [Bug middle-end/105910] __builtin_return_address expansion with a large # causes a compile time issues and even ICEs sometimes pinskia at gcc dot gnu.org
2023-05-17 23:36 ` pinskia at gcc dot gnu.org
2023-05-17 23:39 ` [Bug middle-end/105910] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-07-19 11:03 ` rguenth at gcc dot gnu.org
2023-10-16 14:00 ` pinskia at gcc dot gnu.org
2024-04-11  2:24 ` 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).