diff mbox

[C++] PR 57947

Message ID 51F7B39F.9010301@oracle.com
State New
Headers show

Commit Message

Paolo Carlini July 30, 2013, 12:37 p.m. UTC
Hi,

this issue, error recovery in C++98 mode, is a bit tricky: as far as I 
can see, it boils down to the fact that in C++98 mode we don't want to 
handle specially std::initializer_list. Otherwise, after the error 
message we crash in convert_like_real where we try to handle ck_list, @ 
line 6056. With the below we emit the exact same diagnostic we emit for 
init_list or any other non special name.

Tested x86_64-linux.

Thanks,
Paolo.

////////////////////
/cp
2013-07-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57947
	* call.c (add_list_candidates): Only handle specially totype with
	TYPE_HAS_LIST_CTOR (totype) set if cxx_dialect != cxx98.

/testsuite
2013-07-30  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/57947
	* g++.dg/parse/crash63.C: New.

Comments

Jason Merrill July 30, 2013, 1:30 p.m. UTC | #1
How about just returning false from is_std_init_list in C++98 mode?

Jason
diff mbox

Patch

Index: cp/call.c
===================================================================
--- cp/call.c	(revision 201331)
+++ cp/call.c	(working copy)
@@ -3370,7 +3370,8 @@  add_list_candidates (tree fns, tree first_arg,
     ;
   /* If the class has a list ctor, try passing the list as a single
      argument first, but only consider list ctors.  */
-  else if (TYPE_HAS_LIST_CTOR (totype))
+  else if (TYPE_HAS_LIST_CTOR (totype)
+	   && cxx_dialect != cxx98)
     {
       flags |= LOOKUP_LIST_ONLY;
       args = make_tree_vector_single (init_list);
Index: testsuite/g++.dg/parse/crash63.C
===================================================================
--- testsuite/g++.dg/parse/crash63.C	(revision 0)
+++ testsuite/g++.dg/parse/crash63.C	(working copy)
@@ -0,0 +1,10 @@ 
+// PR c++/57947
+// { dg-options "-std=c++98" }
+
+namespace std
+{
+  template <class E> class initializer_list {};
+  template <int N> struct D { D(initializer_list<int>) {} };
+  D<0> d {1, 2, 3};  // { dg-error "constructor|no matching" }
+  // { dg-warning "initializer list" "" { target *-*-* } 8 }
+}