On Apr 11 2022, Jason Merrill via Gcc-patches wrote:
> diff --git a/gcc/testsuite/g++.dg/opt/const7.C
> b/gcc/testsuite/g++.dg/opt/const7.C
> new file mode 100644
> index 000..5bcf94897a8
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/opt/const7.C
> @@ -0,0 +1,7 @@
> +// PR c++/104142
> +//
Trivial initialization shouldn't bump a variable out of .rodata; if the
result of build_aggr_init is an empty STATEMENT_LIST, throw it away.
Tested x86_64-pc-linux-gnu, applying to trunk.
PR c++/104142
gcc/cp/ChangeLog:
* decl.cc (check_initializer): Check TREE_SIDE_EFFECTS.
gc