diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-03-06 06:24:53 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-03-06 06:24:53 +0000 |
commit | 47608302d0de4e394f30ac92fef32047220d037f (patch) | |
tree | 5cd37847dde8ab2a0d1d2c4aa83f054104f46fc4 | |
parent | d5e30f014b697f1483904a7d214e1a9e124f8534 (diff) | |
download | gcc-47608302d0de4e394f30ac92fef32047220d037f.tar.gz |
[PR c++/84593] ice on braced init with uninit ref field
If an initializer expr is to be NULL in a ctor initializer list, we
ICE in picflag_from_initializer and elsewhere.
If we're missing an initializer for a reference field, we report the
error, but then build a zero initializer to avoid the ICE.
for gcc/cp/ChangeLog
PR c++/84593
* init.c (build_zero_init_1): Zero-initialize references.
for gcc/testsuite/ChangeLog
PR c++/84593
* g++.dg/cpp1y/pr84593.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258270 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/init.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/pr84593.C | 8 |
4 files changed, 18 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cbacda6e382..3623405ded0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2018-03-06 Alexandre Oliva <aoliva@redhat.com> + PR c++/84593 + * init.c (build_zero_init_1): Zero-initialize references. + PR c++/84492 * semantics.c (finish_stmt_expr_expr): Reject unresolved overloads used as stmt expr values. diff --git a/gcc/cp/init.c b/gcc/cp/init.c index d0d14abdc9f..15cee17c780 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -284,7 +284,10 @@ build_zero_init_1 (tree type, tree nelts, bool static_storage_p, else if (VECTOR_TYPE_P (type)) init = build_zero_cst (type); else - gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); + { + gcc_assert (TREE_CODE (type) == REFERENCE_TYPE); + init = build_zero_cst (type); + } /* In all cases, the initializer is a constant. */ if (init) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e3e3262ddf2..9c94d366646 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-03-06 Alexandre Oliva <aoliva@redhat.com> + PR c++/84593 + * g++.dg/cpp1y/pr84593.C: New. + PR c++/84492 * g++.dg/pr84492.C: New. diff --git a/gcc/testsuite/g++.dg/cpp1y/pr84593.C b/gcc/testsuite/g++.dg/cpp1y/pr84593.C new file mode 100644 index 00000000000..8aa869f1919 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr84593.C @@ -0,0 +1,8 @@ +// PR c++/84593 +// { dg-do compile { target c++14 } } + +struct a { + int x; + int c = 0; + int &b; +} c = {}; // { dg-error "uninitialized reference" } |