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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nshead at gcc dot gnu.org
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Nathaniel Shead <nshead at gcc dot gnu.org> ---
Thanks for the report!  As Andrew noted, the ICE is fixed for 14.3 by
r14-10825-g01d3a974fe3474c37cd52b595c29dddafad954dc.

The code is ill-formed, however:

  export module M;
  struct {} instance;

is not legal in a module interface, because of
https://eel.is/c++draft/basic.link#15.2 (the type of the unnamed struct is
TU-local), https://eel.is/c++draft/basic.link#14 (the declaration of the
variable exposes the TU-local type), and https://eel.is/c++draft/basic.link#17
(the variable is not TU-local, so this is ill-formed).

We don't check this in GCC 14 (so 14.3 will accept this code), but for GCC 15
we properly implement https://wg21.link/p1815 and so error in this case:

<source>:2:11: error: 'instance' exposes TU-local entity 'struct<unnamed>'
    2 | struct {} instance;
      |           ^~~~~~~~
<source>:2:8: note: '<unnamed struct>' has no name and is not defined within a
class, function, or initializer
    2 | struct {} instance;
      |        ^

Reply via email to