c++: Fix value-init crash in template [PR93676]
authorMarek Polacek <polacek@redhat.com>
Wed, 19 Feb 2020 20:59:33 +0000 (15:59 -0500)
committerMarek Polacek <polacek@redhat.com>
Wed, 26 Feb 2020 15:33:18 +0000 (10:33 -0500)
commit38e1002657828150b2cda9f80c1f752184286e80
tree848964a3def8a1c117965c14e08b2b68c378cbb8
parent8ce13842b50cbd2676f2e322995182af20df31fe
c++: Fix value-init crash in template [PR93676]

Since <https://gcc.gnu.org/ml/gcc-patches/2015-02/msg00556.html> we
attempt to value-initialize in build_vec_init even when there's no
initializer but the type has a constexpr default constructor.  But
build_value_init doesn't work in templates, and build_vec_init
creates a lot of garbage that would not be used anyway, so don't
call it in a template.

PR c++/93676 - value-init crash in template.
* init.c (build_new_1): Don't call build_vec_init in a template.

* g++.dg/cpp0x/nsdmi-template19.C: New test.
gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nsdmi-template19.C [new file with mode: 0644]