public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/114501] New: ICE during modref with LTO
@ 2024-03-27 20:55 nerixdev at outlook dot de
  2024-03-28  1:55 ` [Bug ipa/114501] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: nerixdev at outlook dot de @ 2024-03-27 20:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114501
           Summary: ICE during modref with LTO
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nerixdev at outlook dot de
  Target Milestone: ---

Created attachment 57822
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57822&action=edit
Preprocessed source

The following C++ 20 code causes an ICE when compiled with -flto:

#include <string_view>
#include <array>

inline constexpr auto make_it()
{
    constexpr std::string_view view{"", 0};
    std::array<char, 1> arr;
    arr[view.size()] = 'a'; // using 0 here won't cause an ICE
    return arr;
}

inline constexpr auto foo = make_it();
auto bar = foo;

---

The same bug happens from GCC 10 to the current version listed as (trunc) on
compiler-explorer: https://godbolt.org/z/xve6h5qhh. I'm using GCC 13.2.0 below.

I've included the .ii file as the attachment.

The code was compiled with g++ -std=c++20 foo.cpp -o foo.o -c -flto.
Output of gcc -v -save-temps <all-your-options> <source-file>:

Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-linux-gnu
Configured with: /usr/src/gcc/configure --build=x86_64-linux-gnu
--disable-multilib --enable-languages=c,c++,fortran,go
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-c' '-flto' '-freport-bug'
'-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc/x86_64-linux-gnu/13.2.0/cc1plus -E -quiet -v
-imultiarch x86_64-linux-gnu -D_GNU_SOURCE foo.cpp -mtune=generic -march=x86-64
-std=c++20 -flto -freport-bug -fpch-preprocess -o foo.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/include-fixed/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0

/usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/x86_64-linux-gnu

/usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/../../../../include/c++/13.2.0/backward
 /usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/include
 /usr/local/include
 /usr/local/lib/gcc/x86_64-linux-gnu/13.2.0/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-c' '-flto' '-freport-bug'
'-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc/x86_64-linux-gnu/13.2.0/cc1plus -fpreprocessed foo.ii
-quiet -dumpbase foo.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64
-std=c++20 -version -flto -freport-bug -o foo.s
GNU C++20 (GCC) version 13.2.0 (x86_64-linux-gnu)
        compiled by GNU C version 13.2.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4919020133b793ebcf160ec1288a96cd
during IPA pass: modref
foo.cpp:13:15: internal compiler error: in streamer_write_chain, at
tree-streamer-out.cc:543
   13 | auto bar = foo;
      |               ^
0x1c989f6 internal_error(char const*, ...)
        ???:0
0x75eba6 fancy_abort(char const*, int, char const*)
        ???:0
0x106eece streamer_write_tree_body(output_block*, tree_node*)
        ???:0
0xd18d4d DFS::DFS(output_block*, tree_node*, bool, bool, bool)
        ???:0
0xd1a1f9 lto_output_tree(output_block*, tree_node*, bool, bool)
        ???:0
0xd1cc43 produce_asm_for_decls()
        ???:0
0xd9c852 ipa_write_summaries()
        ???:0
0xa67be7 symbol_table::finalize_compilation_unit()
        ???:0
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
The bug is not reproducible, so it is likely a hardware or OS problem.

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

* [Bug ipa/114501] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
@ 2024-03-28  1:55 ` pinskia at gcc dot gnu.org
  2024-03-28  2:29 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-28  1:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
      /* We avoid outputting external vars or functions by reference
         to the global decls section as we do not want to have them
         enter decl merging.  We should not need to do this anymore because
         free_lang_data removes them from block scopes.  */
      gcc_assert (!VAR_OR_FUNCTION_DECL_P (t) || !DECL_EXTERNAL (t));

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

* [Bug ipa/114501] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
  2024-03-28  1:55 ` [Bug ipa/114501] " pinskia at gcc dot gnu.org
@ 2024-03-28  2:29 ` pinskia at gcc dot gnu.org
  2024-03-28  2:56 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-28  2:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

* [Bug ipa/114501] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
  2024-03-28  1:55 ` [Bug ipa/114501] " pinskia at gcc dot gnu.org
  2024-03-28  2:29 ` pinskia at gcc dot gnu.org
@ 2024-03-28  2:56 ` pinskia at gcc dot gnu.org
  2024-03-28  2:58 ` [Bug ipa/114501] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-28  2:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 57825
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57825&action=edit
Reduced most of the way (C++14 code now)

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

* [Bug ipa/114501] [11/12/13/14 Regression] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
                   ` (2 preceding siblings ...)
  2024-03-28  2:56 ` pinskia at gcc dot gnu.org
@ 2024-03-28  2:58 ` pinskia at gcc dot gnu.org
  2024-03-28  3:03 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-28  2:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |8.5.0
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-03-28
   Target Milestone|---                         |11.5
            Summary|ICE during modref with LTO  |[11/12/13/14 Regression]
                   |                            |ICE during modref with LTO
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |9.1.0

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
With my reduced testcase it worked in GCC 8.5.0 but started to ICE in GCC 9.

Confirmed.

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

* [Bug ipa/114501] [11/12/13/14 Regression] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
                   ` (3 preceding siblings ...)
  2024-03-28  2:58 ` [Bug ipa/114501] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2024-03-28  3:03 ` pinskia at gcc dot gnu.org
  2024-03-28  3:05 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-28  3:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #57825|0                           |1
        is obsolete|                            |

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Created attachment 57826
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57826&action=edit
Reduced the rest of the way

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

* [Bug ipa/114501] [11/12/13/14 Regression] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
                   ` (4 preceding siblings ...)
  2024-03-28  3:03 ` pinskia at gcc dot gnu.org
@ 2024-03-28  3:05 ` pinskia at gcc dot gnu.org
  2024-03-28  8:06 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-28  3:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Changing he return type of size to be size_t rather than size_type fixes the
issue.

So does adding:
constexpr basic_string_view view;
to the toplevel namespace.

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

* [Bug ipa/114501] [11/12/13/14 Regression] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
                   ` (5 preceding siblings ...)
  2024-03-28  3:05 ` pinskia at gcc dot gnu.org
@ 2024-03-28  8:06 ` rguenth at gcc dot gnu.org
  2024-03-29 23:48 ` law at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-03-28  8:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
The assert basically verifies free-lang-data does its job.

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

* [Bug ipa/114501] [11/12/13/14 Regression] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
                   ` (6 preceding siblings ...)
  2024-03-28  8:06 ` rguenth at gcc dot gnu.org
@ 2024-03-29 23:48 ` law at gcc dot gnu.org
  2024-04-08  9:44 ` sjames at gcc dot gnu.org
  2024-04-08  9:50 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-29 23:48 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1
                 CC|                            |law at gcc dot gnu.org

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

* [Bug ipa/114501] [11/12/13/14 Regression] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
                   ` (7 preceding siblings ...)
  2024-03-29 23:48 ` law at gcc dot gnu.org
@ 2024-04-08  9:44 ` sjames at gcc dot gnu.org
  2024-04-08  9:50 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: sjames at gcc dot gnu.org @ 2024-04-08  9:44 UTC (permalink / raw)
  To: gcc-bugs

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

Sam James <sjames at gcc dot gnu.org> changed:

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

--- Comment #8 from Sam James <sjames at gcc dot gnu.org> ---
This can be downgraded from P1 given we released with it.

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

* [Bug ipa/114501] [11/12/13/14 Regression] ICE during modref with LTO
  2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
                   ` (8 preceding siblings ...)
  2024-04-08  9:44 ` sjames at gcc dot gnu.org
@ 2024-04-08  9:50 ` rguenth at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-04-08  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|14.0                        |13.2.0
           Priority|P1                          |P2

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
It was also reported against 13.2.

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

end of thread, other threads:[~2024-04-08  9:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27 20:55 [Bug ipa/114501] New: ICE during modref with LTO nerixdev at outlook dot de
2024-03-28  1:55 ` [Bug ipa/114501] " pinskia at gcc dot gnu.org
2024-03-28  2:29 ` pinskia at gcc dot gnu.org
2024-03-28  2:56 ` pinskia at gcc dot gnu.org
2024-03-28  2:58 ` [Bug ipa/114501] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2024-03-28  3:03 ` pinskia at gcc dot gnu.org
2024-03-28  3:05 ` pinskia at gcc dot gnu.org
2024-03-28  8:06 ` rguenth at gcc dot gnu.org
2024-03-29 23:48 ` law at gcc dot gnu.org
2024-04-08  9:44 ` sjames at gcc dot gnu.org
2024-04-08  9:50 ` 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).