From: Alexandre Oliva <aoliva@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PR c++/84593] ice on braced init with uninit ref field
Date: Wed, 28 Feb 2018 12:08:00 -0000 [thread overview]
Message-ID: <orbmg9pb95.fsf@lxoliva.fsfla.org> (raw)
Don't allow the initializer expr to be NULL in a ctor initializer
list, make it error_marker_node instead.
Regstrapped on x86_64- and i686-linux-gnu. Ok to install?
for gcc/cp/ChangeLog
PR c++/84593
* typeck2.c (process_init_constructor_record): Set NULL next
to error_marker_node.
for gcc/testsuite/ChangeLog
PR c++/84593
* g++.dg/cpp1y/pr84593.C: New.
---
gcc/cp/typeck2.c | 2 ++
gcc/testsuite/g++.dg/cpp1y/pr84593.C | 8 ++++++++
2 files changed, 10 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr84593.C
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 153b46cca775..8c2aa3ed55a5 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1529,6 +1529,8 @@ process_init_constructor_record (tree type, tree init, int nested,
/* If this is a bitfield, now convert to the lowered type. */
if (type != TREE_TYPE (field))
next = cp_convert_and_check (TREE_TYPE (field), next, complain);
+ if (!next)
+ next = error_mark_node;
flags |= picflag_from_initializer (next);
CONSTRUCTOR_APPEND_ELT (v, field, next);
}
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr84593.C b/gcc/testsuite/g++.dg/cpp1y/pr84593.C
new file mode 100644
index 000000000000..8aa869f19193
--- /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" }
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
next reply other threads:[~2018-02-28 12:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-28 12:08 Alexandre Oliva [this message]
2018-02-28 18:57 ` Jason Merrill
2018-03-02 7:57 ` Alexandre Oliva
2018-03-02 19:02 ` Jason Merrill
2018-03-06 5:43 ` Alexandre Oliva
2018-03-06 15:28 ` Jason Merrill
2018-03-06 6:14 ` Alexandre Oliva
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=orbmg9pb95.fsf@lxoliva.fsfla.org \
--to=aoliva@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).