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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ICE when using              |[16 Regression] ICE when
                   |std::make_unique inside a   |using std::make_unique
                   |module                      |inside a module
                 CC|                            |nshead at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |ice-on-valid-code
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2026-03-07

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

This particular testcase is emitting way too much into the module CMI; in
particular, we shouldn't need to make bindings for hidden declarations, as
hidden friends always be found and made reachable via the class type anyway
(and don't need bindings regardless), while we probably actively don't want to
be emitting the hidden builtin declarations.

I suspect this bug was caused by the fix for PR122994, which stopped making
dependencies for keyed lambdas of an entity as part of streaming and relied on
them being discovered and dep'd by function definition streaming.  But in this
case we don't stream the function definition so it's not safe, and we still end
up streaming the key-decl entities and crash when asserting we got a sensible
result.

The following WIP patch fixes the testcase and reduces the total number of
entities written from 8525 (GCC15 -std=c++26) to 2.  But I'm not sure the
following patch would be appropriate for GCC16 given how late into stage 4 we
are, I'll need to reduce a testcase to explore if there are more targetted
fixes we could make.

diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index ccbf124876d..6a0989cd233 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -14697,7 +14697,11 @@ depset::hash::make_dependency (tree decl, entity_kind
ek)
               && !DECL_ARTIFICIAL (decl)
               /* A hidden friend doesn't need a binding.  */
               && !(DECL_LANG_SPECIFIC (not_tmpl)
-                   && DECL_UNIQUE_FRIEND_P (not_tmpl)))
+                   && DECL_UNIQUE_FRIEND_P (not_tmpl))
+              /* FIXME hidden builtins made visible by local alias,
+                 see local-extern-2.H  */
+              && !(DECL_LANG_SPECIFIC (not_tmpl)
+                   && DECL_MODULE_PURVIEW_P (not_tmpl)))
             {
               /* This will only affect GM functions.  */
               gcc_checking_assert (!DECL_LANG_SPECIFIC (not_tmpl)
@@ -14918,6 +14922,9 @@ depset::hash::add_binding_entity (tree decl, WMB_Flags
flags, void *data_)
            than trying to clear out bindings after the fact.  */
         return false;

+      if (flags & WMB_Hidden)
+        return false;
+
       bool internal_decl = false;
       if (!header_module_p () && is_tu_local_entity (decl))
         {

Reply via email to