c++: Fix constexpr array ICE [PR98332]
authorJason Merrill <jason@redhat.com>
Tue, 22 Dec 2020 21:40:37 +0000 (16:40 -0500)
committerJason Merrill <jason@redhat.com>
Wed, 23 Dec 2020 21:40:17 +0000 (16:40 -0500)
commit6b7d53a25933f4aed71d6d5134e971bd995f8973
treeb407f4eb8227d21074b79e8a5b662632634fd745
parent96de87b99bf8fd1c46df373bbcc2f7d76db716ad
c++: Fix constexpr array ICE [PR98332]

The element initializer was non-constant, so its CONSTRUCTOR element ended
up NULL, so unshare_constructor crashed trying to look at it.  This patch
fixes this in two places: First, by returning when we see a non-constant
initializer; second, by not crashing on NULL.

gcc/cp/ChangeLog:

PR c++/98332
* constexpr.c (unshare_constructor): Check for NULL.
(cxx_eval_vec_init_1): Always exit early if non-constant.

gcc/testsuite/ChangeLog:

PR c++/98332
* g++.dg/cpp0x/constexpr-overflow3.C: New test.
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/cpp0x/constexpr-overflow3.C [new file with mode: 0644]