]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++/modules: Warn for optimize attributes instead of ICEing [PR108080]
authorNathaniel Shead <nathanieloshead@gmail.com>
Tue, 29 Jul 2025 11:46:59 +0000 (21:46 +1000)
committerNathaniel Shead <nathanieloshead@gmail.com>
Fri, 1 Aug 2025 02:34:00 +0000 (12:34 +1000)
commitebfe7bc7d9572c6449848d0362c738b0fafd4fbe
tree0bc093728ed5c47f3fd9f26b4d49ece786484ebe
parent16e8d1479f60ea22ba604ac4217d5745c7c80b98
c++/modules: Warn for optimize attributes instead of ICEing [PR108080]

This PR is the most frequently reported modules bug for 15, as the ICE
message does not indicate the issue at all and reducing to find the
underlying cause can be tricky.

I have a WIP patch to fix this issue by just reconstructing these nodes
on stream-in from any attributes applied to the functions, but since at
this stage it may still take a while to be ready, it seems useful to me
to at least make the error here more friendly and guide users to what
they could do to work around this issue.

In fact, as noted on the PR, a lot of the time it should be harmless to
just ignore the optimize etc. attribute and continue translation, at the
user's own risk; this patch as such turns the ICE into a warning with no
option to silence.

PR c++/108080

gcc/cp/ChangeLog:

* module.cc (trees_out::core_vals): Warn when streaming
target/optimize node; adjust comments.
(trees_in::core_vals): Don't stream a target/optimize node.

gcc/testsuite/ChangeLog:

* g++.dg/modules/pr108080.H: 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 643c5b42e21dbc02e9bde01865c880b26aa5f938)
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/pr108080.H [new file with mode: 0644]