This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH for c++/43079 (ice-on-invalid pointer-to-member template argument)

The patch for PR 561 fixed G++ to use the function type independent of the member qualifier for resolving an overloaded function, which allows us to violate the assert here. Fixed the ICE by changing the assert to a test to control the extra helpful message.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit afdae7962c2c0c1221a57cb1cd8677407e98fb4a
Author: Jason Merrill <>
Date:   Tue Feb 16 14:04:38 2010 -0500

    	PR c++/43079
    	* pt.c (convert_nontype_argument): Change assert to test.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 43cd105..0165a7d 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5128,12 +5128,13 @@ convert_nontype_argument (tree type, tree expr)
 	 provide a superior diagnostic.  */
       if (!same_type_p (TREE_TYPE (expr), type))
-	  /* Make sure we are just one standard conversion off.  */
-	  gcc_assert (can_convert (type, TREE_TYPE (expr)));
 	  error ("%qE is not a valid template argument for type %qT "
 		 "because it is of type %qT", expr, type,
 		 TREE_TYPE (expr));
-	  inform (input_location, "standard conversions are not allowed in this context");
+	  /* If we are just one standard conversion off, explain.  */
+	  if (can_convert (type, TREE_TYPE (expr)))
+	    inform (input_location,
+		    "standard conversions are not allowed in this context");
 	  return NULL_TREE;
diff --git a/gcc/testsuite/g++.dg/template/ptrmem20.C b/gcc/testsuite/g++.dg/template/ptrmem20.C
new file mode 100644
index 0000000..d98ef39
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ptrmem20.C
@@ -0,0 +1,16 @@
+// PR c++/43079
+struct A {};
+struct B
+  void foo() const;
+  void foo();
+template<void (A::*)()> void bar();
+void baz()
+  bar<&B::foo>();  // { dg-error "not a valid template argument|no match" }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]