[Bug c++/120363] internal compiler error: in tree_node, at cp/module.cc:9956

2025-05-23 Thread nshead at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120363

Nathaniel Shead  changed:

   What|Removed |Added

 Resolution|--- |FIXED
   Target Milestone|--- |15.2
 Status|ASSIGNED|RESOLVED

--- Comment #5 from Nathaniel Shead  ---
Fixed on trunk and for 15.2; thanks for the report!

[Bug c++/120363] internal compiler error: in tree_node, at cp/module.cc:9956

2025-05-23 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120363

--- Comment #4 from GCC Commits  ---
The releases/gcc-15 branch has been updated by Nathaniel Shead
:

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

commit r15-9724-ga8f62a9b32668ea77da721cdc8b9403e507637af
Author: Nathaniel Shead 
Date:   Thu May 22 22:16:22 2025 +1000

c++/modules: Fix merge of TLS init functions [PR120363]

The PR notes that we missed setting DECL_CONTEXT on the TLS init
function; we missed this initially because this function is not created
in header units, only named modules.

I also noticed that 'DECL_CONTEXT (fn) = DECL_CONTEXT (var)' was
incorrect: for class members, this ends up having the modules merging
machinery treat the decl as a member function, which breaks when
attempting to dedup against an existing completed class type.  Instead
we can just use the global_namespace as the context, because the name of
the function is already mangled appropriately so that we'll match the
correct duplicates.

PR c++/120363

gcc/cp/ChangeLog:

* decl2.cc (get_tls_init_fn): Set context as global_namespace.
(get_tls_wrapper_fn): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr113292_a.H: Move to...
* g++.dg/modules/tls-1_a.H: ...here.
* g++.dg/modules/pr113292_b.C: Move to...
* g++.dg/modules/tls-1_b.C: ...here.
* g++.dg/modules/pr113292_c.C: Move to...
* g++.dg/modules/tls-1_c.C: ...here.
* g++.dg/modules/tls-2_a.C: New test.
* g++.dg/modules/tls-2_b.C: New test.
* g++.dg/modules/tls-2_c.C: New test.
* g++.dg/modules/tls-3.h: New test.
* g++.dg/modules/tls-3_a.H: New test.
* g++.dg/modules/tls-3_b.C: New test.

Signed-off-by: Nathaniel Shead 
Reviewed-by: Jason Merrill 
(cherry picked from commit 66e9a4f3083356b064cc64651edad466a56f762b)

[Bug c++/120363] internal compiler error: in tree_node, at cp/module.cc:9956

2025-05-23 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120363

--- Comment #3 from GCC Commits  ---
The master branch has been updated by Nathaniel Shead :

https://gcc.gnu.org/g:66e9a4f3083356b064cc64651edad466a56f762b

commit r16-856-g66e9a4f3083356b064cc64651edad466a56f762b
Author: Nathaniel Shead 
Date:   Thu May 22 22:16:22 2025 +1000

c++/modules: Fix merge of TLS init functions [PR120363]

The PR notes that we missed setting DECL_CONTEXT on the TLS init
function; we missed this initially because this function is not created
in header units, only named modules.

I also noticed that 'DECL_CONTEXT (fn) = DECL_CONTEXT (var)' was
incorrect: for class members, this ends up having the modules merging
machinery treat the decl as a member function, which breaks when
attempting to dedup against an existing completed class type.  Instead
we can just use the global_namespace as the context, because the name of
the function is already mangled appropriately so that we'll match the
correct duplicates.

PR c++/120363

gcc/cp/ChangeLog:

* decl2.cc (get_tls_init_fn): Set context as global_namespace.
(get_tls_wrapper_fn): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr113292_a.H: Move to...
* g++.dg/modules/tls-1_a.H: ...here.
* g++.dg/modules/pr113292_b.C: Move to...
* g++.dg/modules/tls-1_b.C: ...here.
* g++.dg/modules/pr113292_c.C: Move to...
* g++.dg/modules/tls-1_c.C: ...here.
* g++.dg/modules/tls-2_a.C: New test.
* g++.dg/modules/tls-2_b.C: New test.
* g++.dg/modules/tls-2_c.C: New test.
* g++.dg/modules/tls-3.h: New test.
* g++.dg/modules/tls-3_a.H: New test.
* g++.dg/modules/tls-3_b.C: New test.

Signed-off-by: Nathaniel Shead 
Reviewed-by: Jason Merrill 

[Bug c++/120363] internal compiler error: in tree_node, at cp/module.cc:9956

2025-05-20 Thread nshead at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120363

Nathaniel Shead  changed:

   What|Removed |Added

   Last reconfirmed||2025-05-21
 Ever confirmed|0   |1
 CC||nshead at gcc dot gnu.org
 Status|UNCONFIRMED |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |nshead at gcc dot 
gnu.org

--- Comment #2 from Nathaniel Shead  ---
Confirmed.  Reduced:

  export module M;
  struct S {
static thread_local int thread_singleton;
inline static int& get_singleton() { return thread_singleton; }
  };

We're not setting DECL_CONTEXT on the TLS init func.

[Bug c++/120363] internal compiler error: in tree_node, at cp/module.cc:9956

2025-05-20 Thread gcc at acb dot anonaddy.me via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120363

--- Comment #1 from ACB  ---
Created attachment 61476
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61476&action=edit
freport-bug