Skip to content
Snippets Groups Projects
Commit a71c3977 authored by Nathaniel Shead's avatar Nathaniel Shead
Browse files

c++: Fix ICE when writing nontrivial variable initializers


The attached testcase Patrick found in PR c++/112899 ICEs because it is
attempting to write a variable initializer that is no longer in the
static_aggregates map.

The issue is that, for non-header modules, the loop in
c_parse_final_cleanups prunes the static_aggregates list, which means
that by the time we get to emitting module information those
initialisers have been lost.

However, we don't actually need to write non-trivial initialisers for
non-header modules, because they've already been emitted as part of the
module TU itself.  Instead let's just only write the initializers from
header modules (which skipped writing them in c_parse_final_cleanups).

gcc/cp/ChangeLog:

	* module.cc (trees_out::write_var_def): Only write initializers
	in header modules.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/init-5_a.C: New test.
	* g++.dg/modules/init-5_b.C: New test.

Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
parent 63b531e6
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment