aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-09-22 10:54:28 +0100
committerJason Merrill <jason@redhat.com>2023-09-22 14:22:26 +0100
commit22cda0ca5fb406f22925bbf51ab152a958e3319d (patch)
tree6e35d8cdb169e584e492e54ef7026d3198f71172 /gcc/cp/constexpr.cc
parent9c62af101e11e1cce573c2b3d2e18b403412dbc8 (diff)
downloadgcc-22cda0ca5fb406f22925bbf51ab152a958e3319d.zip
gcc-22cda0ca5fb406f22925bbf51ab152a958e3319d.tar.gz
gcc-22cda0ca5fb406f22925bbf51ab152a958e3319d.tar.bz2
c++: constexpr and designated initializer
The change of active member being non-constant (before C++20) results in a CONSTRUCTOR with a null value for the first field, don't crash. gcc/cp/ChangeLog: * constexpr.cc (free_constructor): Handle null ce->value. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-union7.C: New test.
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r--gcc/cp/constexpr.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index a673a60..2a6601c 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -1753,7 +1753,7 @@ free_constructor (tree t)
{
constructor_elt *ce;
for (HOST_WIDE_INT i = 0; vec_safe_iterate (elts, i, &ce); ++i)
- if (TREE_CODE (ce->value) == CONSTRUCTOR)
+ if (ce->value && TREE_CODE (ce->value) == CONSTRUCTOR)
vec_safe_push (ctors, ce->value);
ggc_free (elts);
}