public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114856] New: [14 regression][modules] ICE (segfault)
@ 2024-04-25 20:20 D.Klein at gsi dot de
  2024-04-26  2:01 ` [Bug c++/114856] " nshead at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: D.Klein at gsi dot de @ 2024-04-25 20:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114856
           Summary: [14 regression][modules] ICE (segfault)
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: D.Klein at gsi dot de
  Target Milestone: ---

Created attachment 58042
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58042&action=edit
/tmp/ccHpxCro.out - preprocessed source

❯ cat repro.cpp
module;

#include <array>
#include <string>
#include <vector>

export module repro;

export struct data {
  std::vector<std::array<std::string, 3>> asdf{{"42","42","42"}};
};

❯ g++ -v -save-temps -freport-bug -fmodules-ts repro.cpp
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/home/dklein/gcc-master/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ./configure --prefix=/home/dklein/gcc-master
--disable-multilib --disable-bootstrap : (reconfigured) ./configure
--prefix=/home/dklein/gcc-master --disable-multilib --disable-bootstrap :
(reconfigured) ./configure --prefix=/home/dklein/gcc-master --disable-multilib
--disable-bootstrap --enable-languages=c,c++,fortran,lto,objc --no-create
--no-recursion
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240425 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-freport-bug' '-fmodules-ts'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /home/dklein/gcc-master/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/cc1plus -E
-quiet -v -D_GNU_SOURCE repro.cpp -mtune=generic -march=x86-64 -freport-bug
-fmodules-ts -fpch-preprocess -o a-repro.ii
ignoring nonexistent directory
"/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/../../../../include/c++/14.0.1

/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/../../../../include/c++/14.0.1/x86_64-pc-linux-gnu

/home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/../../../../include/c++/14.0.1/backward
 /home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/include
 /usr/local/include
 /home/dklein/gcc-master/include
 /home/dklein/gcc-master/lib/gcc/x86_64-pc-linux-gnu/14.0.1/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-freport-bug' '-fmodules-ts'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /home/dklein/gcc-master/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/cc1plus
-fpreprocessed a-repro.ii -quiet -dumpdir a- -dumpbase repro.cpp -dumpbase-ext
.cpp -mtune=generic -march=x86-64 -version -freport-bug -fmodules-ts -o
a-repro.s
GNU C++17 (GCC) version 14.0.1 20240425 (experimental) (x86_64-pc-linux-gnu)
        compiled by GNU C version 14.0.1 20240411 (Red Hat 14.0.1-0), GMP
version 6.2.1, MPFR version 4.2.1, MPC version 1.3.1, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 66103b0a3eb595c28eae89ea7eb332ba
repro.cpp:7:9: internal compiler error: Segmentation fault
    7 | export module repro;
      |         ^~~~~~
0x12ff8df crash_signal
        ../.././gcc/toplev.cc:319
0xb512ae tree_check(tree_node*, char const*, int, char const*, tree_code)
        ../.././gcc/tree.h:3623
0xb512ae get_merge_kind
        ../.././gcc/cp/module.cc:10679
0xb512ae decl_value
        ../.././gcc/cp/module.cc:7787
0xb5a4a3 depset::hash::find_dependencies(module_state*)
        ../.././gcc/cp/module.cc:13592
0xb5b2f3 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
        ../.././gcc/cp/module.cc:18198
0xb5c9a4 finish_module_processing(cpp_reader*)
        ../.././gcc/cp/module.cc:20562
0xae6ee1 c_parse_final_cleanups()
        ../.././gcc/cp/decl2.cc:5357
0xd37c50 c_common_parse_file()
        ../.././gcc/c-family/c-opts.cc:1329
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.
Preprocessed source stored into /tmp/ccHpxCro.out file, please attach this to
your bugreport.

repro.cpp compiles with GCC 13.2.0 (https://godbolt.org/z/Ph834fvja). A git
bisect from 1604f7cebc49220e47d584615bcd91b1fdc1267f to releases/gcc-13.2.0
suggests the following commit to introduce the regression:

commit 2823b4d96d9ec4ad4e67e5e8edaa1b060a467491
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Thu Feb 29 22:49:13 2024 +1100

    c++: Ensure DECL_CONTEXT is set for temporary vars [PR114005]

    Modules streaming requires DECL_CONTEXT to be set for anything streamed.
    This patch ensures that 'create_temporary_var' does set a DECL_CONTEXT
    for these variables (such as the backing storage for initializer_lists)
    even if not inside a function declaration.

            PR c++/114005

    gcc/cp/ChangeLog:

            * init.cc (create_temporary_var): Use current_scope instead of
            current_function_decl.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/pr114005_a.C: New test.
            * g++.dg/modules/pr114005_b.C: New test.

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>

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

* [Bug c++/114856] [14 regression][modules] ICE (segfault)
  2024-04-25 20:20 [Bug c++/114856] New: [14 regression][modules] ICE (segfault) D.Klein at gsi dot de
@ 2024-04-26  2:01 ` nshead at gcc dot gnu.org
  2024-04-26 14:25 ` [Bug c++/114856] [14/15 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-04-26  2:01 UTC (permalink / raw)
  To: gcc-bugs

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

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |nshead at gcc dot gnu.org
   Last reconfirmed|                            |2024-04-26
           Assignee|unassigned at gcc dot gnu.org      |nshead at gcc dot gnu.org

--- Comment #1 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Minimised:


module;
namespace std {
  template <class> struct initializer_list {
    int *_M_array;
    unsigned long _M_len;
  };
  struct basic_string {
    ~basic_string();
  };
}
export module repro;
struct A {
  std::basic_string data3;
};
struct V {
  V(std::initializer_list<A>);
};
struct data {
  V v{{}};
};

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

* [Bug c++/114856] [14/15 regression][modules] ICE (segfault)
  2024-04-25 20:20 [Bug c++/114856] New: [14 regression][modules] ICE (segfault) D.Klein at gsi dot de
  2024-04-26  2:01 ` [Bug c++/114856] " nshead at gcc dot gnu.org
@ 2024-04-26 14:25 ` rguenth at gcc dot gnu.org
  2024-05-07  7:45 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-04-26 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

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

* [Bug c++/114856] [14/15 regression][modules] ICE (segfault)
  2024-04-25 20:20 [Bug c++/114856] New: [14 regression][modules] ICE (segfault) D.Klein at gsi dot de
  2024-04-26  2:01 ` [Bug c++/114856] " nshead at gcc dot gnu.org
  2024-04-26 14:25 ` [Bug c++/114856] [14/15 " rguenth at gcc dot gnu.org
@ 2024-05-07  7:45 ` rguenth at gcc dot gnu.org
  2024-05-07 23:17 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-07  7:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |14.2

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 14.1 is being released, retargeting bugs to GCC 14.2.

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

* [Bug c++/114856] [14/15 regression][modules] ICE (segfault)
  2024-04-25 20:20 [Bug c++/114856] New: [14 regression][modules] ICE (segfault) D.Klein at gsi dot de
                   ` (2 preceding siblings ...)
  2024-05-07  7:45 ` rguenth at gcc dot gnu.org
@ 2024-05-07 23:17 ` cvs-commit at gcc dot gnu.org
  2024-05-07 23:21 ` cvs-commit at gcc dot gnu.org
  2024-05-07 23:22 ` nshead at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-07 23:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nshead@gcc.gnu.org>:

https://gcc.gnu.org/g:e60032b382364897a58e67994baac896bcd03327

commit r15-310-ge60032b382364897a58e67994baac896bcd03327
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Tue Apr 30 22:29:57 2024 +1000

    c++/modules: Stream unmergeable temporaries by value again [PR114856]

    In r14-9266-g2823b4d96d9ec4 I gave all temporary vars a DECL_CONTEXT,
    including those at namespace or global scope, so that they could be
    properly merged across importers.  However, not all of these temporary
    vars are actually supposed to be mergeable.

    For instance, in the attached testcase we have an unnamed temporary var
    used in the NSDMI of a class member, which cannot properly merged -- but
    it also doesn't need to be, as it'll be thrown away when the class type
    itself is merged anyway.

    This patch reverts the change made above and instead makes a weaker
    adjustment that only causes temporary vars with linkage have a
    DECL_CONTEXT to merge from.  This way these unnamed, "unmergeable"
    temporaries are properly streamed by value again.

            PR c++/114856

    gcc/cp/ChangeLog:

            * call.cc (make_temporary_var_for_ref_to_temp): Set context for
            temporaries with linkage.
            * init.cc (create_temporary_var): Revert to only set context
            when in a function decl.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/pr114856.h: New test.
            * g++.dg/modules/pr114856_a.H: New test.
            * g++.dg/modules/pr114856_b.C: New test.

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
    Reviewed-by: Jason Merrill <jason@redhat.com>
    Reviewed-by: Patrick Palka <ppalka@redhat.com>

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

* [Bug c++/114856] [14/15 regression][modules] ICE (segfault)
  2024-04-25 20:20 [Bug c++/114856] New: [14 regression][modules] ICE (segfault) D.Klein at gsi dot de
                   ` (3 preceding siblings ...)
  2024-05-07 23:17 ` cvs-commit at gcc dot gnu.org
@ 2024-05-07 23:21 ` cvs-commit at gcc dot gnu.org
  2024-05-07 23:22 ` nshead at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-07 23:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Nathaniel Shead
<nshead@gcc.gnu.org>:

https://gcc.gnu.org/g:61a095b05c244a6e0b1aec36ee1607def00654ab

commit r14-10182-g61a095b05c244a6e0b1aec36ee1607def00654ab
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Tue Apr 30 22:29:57 2024 +1000

    c++/modules: Stream unmergeable temporaries by value again [PR114856]

    In r14-9266-g2823b4d96d9ec4 I gave all temporary vars a DECL_CONTEXT,
    including those at namespace or global scope, so that they could be
    properly merged across importers.  However, not all of these temporary
    vars are actually supposed to be mergeable.

    For instance, in the attached testcase we have an unnamed temporary var
    used in the NSDMI of a class member, which cannot properly merged -- but
    it also doesn't need to be, as it'll be thrown away when the class type
    itself is merged anyway.

    This patch reverts the change made above and instead makes a weaker
    adjustment that only causes temporary vars with linkage have a
    DECL_CONTEXT to merge from.  This way these unnamed, "unmergeable"
    temporaries are properly streamed by value again.

            PR c++/114856

    gcc/cp/ChangeLog:

            * call.cc (make_temporary_var_for_ref_to_temp): Set context for
            temporaries with linkage.
            * init.cc (create_temporary_var): Revert to only set context
            when in a function decl.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/pr114856.h: New test.
            * g++.dg/modules/pr114856_a.H: New test.
            * g++.dg/modules/pr114856_b.C: New test.

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
    Reviewed-by: Jason Merrill <jason@redhat.com>
    Reviewed-by: Patrick Palka <ppalka@redhat.com>
    (cherry picked from commit e60032b382364897a58e67994baac896bcd03327)

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

* [Bug c++/114856] [14/15 regression][modules] ICE (segfault)
  2024-04-25 20:20 [Bug c++/114856] New: [14 regression][modules] ICE (segfault) D.Klein at gsi dot de
                   ` (4 preceding siblings ...)
  2024-05-07 23:21 ` cvs-commit at gcc dot gnu.org
@ 2024-05-07 23:22 ` nshead at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: nshead at gcc dot gnu.org @ 2024-05-07 23:22 UTC (permalink / raw)
  To: gcc-bugs

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

Nathaniel Shead <nshead at gcc dot gnu.org> changed:

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

--- Comment #5 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Fixed for GCC 14.2 and trunk.

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

end of thread, other threads:[~2024-05-07 23:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-25 20:20 [Bug c++/114856] New: [14 regression][modules] ICE (segfault) D.Klein at gsi dot de
2024-04-26  2:01 ` [Bug c++/114856] " nshead at gcc dot gnu.org
2024-04-26 14:25 ` [Bug c++/114856] [14/15 " rguenth at gcc dot gnu.org
2024-05-07  7:45 ` rguenth at gcc dot gnu.org
2024-05-07 23:17 ` cvs-commit at gcc dot gnu.org
2024-05-07 23:21 ` cvs-commit at gcc dot gnu.org
2024-05-07 23:22 ` nshead 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).