* C++ PATCH for c++/79607, ICE with T{} initializer
@ 2017-02-20 6:01 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2017-02-20 6:01 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 169 bytes --]
type_dependent_init_p was overlooking the possibility of a CONSTRUCTOR
with a dependent type, which we can get from T{}.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 79607.diff --]
[-- Type: text/plain, Size: 1049 bytes --]
commit 060f95851e7f6d6737937b786c0a6b29cda3c454
Author: Jason Merrill <jason@redhat.com>
Date: Sun Feb 19 15:40:39 2017 -0800
PR c++/79607 - ICE with T{} initializer
* decl.c (type_dependent_init_p): Check the type of a CONSTRUCTOR.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 70c44fb..e5c2bab 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6662,6 +6662,9 @@ type_dependent_init_p (tree init)
else if (TREE_CODE (init) == CONSTRUCTOR)
/* A brace-enclosed initializer, e.g.: int i = { 3 }; ? */
{
+ if (dependent_type_p (TREE_TYPE (init)))
+ return true;
+
vec<constructor_elt, va_gc> *elts;
size_t nelts;
size_t i;
diff --git a/gcc/testsuite/g++.dg/template/init11.C b/gcc/testsuite/g++.dg/template/init11.C
new file mode 100644
index 0000000..ef337c0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/init11.C
@@ -0,0 +1,9 @@
+// PR c++/79607
+// { dg-do compile { target c++11 } }
+
+template<typename T> struct A
+{
+ static const int i = int{T{}};
+};
+
+A<int> a;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-02-20 5:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-20 6:01 C++ PATCH for c++/79607, ICE with T{} initializer Jason Merrill
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).