Commit 92a1d87
c++: fix constexpr union with empty member [PR123346]
r14-2820 changed cxx_eval_bare_aggregate to set no_slot based on whether
new_ctx.ctor is NULL_TREE, to handle empty subobject elision. However
this incorrectly omits entries for empty union members, which later need
the entry to exist.
This caused valid code to be rejected as non-constant after gcc 13.3,
and in trunk caused an ICE when the diagnostic code tries to print a
CONSTRUCTOR with a null value.
PR c++/123346
gcc/cp/ChangeLog:
* constexpr.cc (init_subob_ctx): Do initialize new_ctx.ctor
for an empty union member.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/constexpr-union10.C: New test.
Signed-off-by: Egas Ribeiro <egas.g.ribeiro@gmail.com>
Co-authored-by: Jason Merrill <jason@redhat.com>1 parent 13e1fc2 commit 92a1d87
2 files changed
Lines changed: 22 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6692 | 6692 | | |
6693 | 6693 | | |
6694 | 6694 | | |
| 6695 | + | |
| 6696 | + | |
| 6697 | + | |
| 6698 | + | |
| 6699 | + | |
| 6700 | + | |
| 6701 | + | |
| 6702 | + | |
| 6703 | + | |
6695 | 6704 | | |
6696 | | - | |
| 6705 | + | |
6697 | 6706 | | |
6698 | 6707 | | |
6699 | 6708 | | |
| |||
6712 | 6721 | | |
6713 | 6722 | | |
6714 | 6723 | | |
6715 | | - | |
6716 | | - | |
6717 | | - | |
| 6724 | + | |
| 6725 | + | |
| 6726 | + | |
| 6727 | + | |
6718 | 6728 | | |
6719 | 6729 | | |
6720 | 6730 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments