diff mbox

[C++] PR 44625

Message ID 4C31C773.3050000@oracle.com
State New
Headers show

Commit Message

Paolo Carlini July 5, 2010, 11:52 a.m. UTC
Hi,

I have this patchlet for another case where we use BASELINK_P on
NULL_TREE. Tested x86_64-linux. I propose to apply it to mainline and
4_5-branch only and then close the PR: it's a regression, but just a P5
ice-on-invalid.

Thanks,
Paolo.

//////////////////
/cp
2010-07-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/44625
	* pt.c (tsubst_copy_and_build): Do not apply BASELINK_P on
	NULL_TREE.

/testsuite
2010-07-05  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/44625
	* g++.dg/template/crash102.C: New.

Comments

Jason Merrill July 5, 2010, 1:10 p.m. UTC | #1
On 07/05/2010 07:52 AM, Paolo Carlini wrote:
> I have this patchlet for another case where we use BASELINK_P on
> NULL_TREE. Tested x86_64-linux. I propose to apply it to mainline and
> 4_5-branch only and then close the PR: it's a regression, but just a P5
> ice-on-invalid.

Seems like we ought to catch this when we're creating the COMPONENT_REF, 
rather than when we're trying to substitute into it; we shouldn't create 
a COMPONENT_REF with a null operand 1.

Jason
Paolo Carlini July 5, 2010, 1:11 p.m. UTC | #2
On 07/05/2010 03:10 PM, Jason Merrill wrote:
> On 07/05/2010 07:52 AM, Paolo Carlini wrote:
>> I have this patchlet for another case where we use BASELINK_P on
>> NULL_TREE. Tested x86_64-linux. I propose to apply it to mainline and
>> 4_5-branch only and then close the PR: it's a regression, but just a P5
>> ice-on-invalid.
> Seems like we ought to catch this when we're creating the
> COMPONENT_REF, rather than when we're trying to substitute into it; we
> shouldn't create a COMPONENT_REF with a null operand 1.
Ok, I'll look into it.

Paolo.
diff mbox

Patch

Index: testsuite/g++.dg/template/crash102.C
===================================================================
--- testsuite/g++.dg/template/crash102.C	(revision 0)
+++ testsuite/g++.dg/template/crash102.C	(revision 0)
@@ -0,0 +1,19 @@ 
+// PR c++/44625
+// { dg-do compile }
+// { dg-options "" }
+
+template<typename FP_> struct Vec { // { dg-message "note" }
+    Vec& operator^=(Vec& rhs)     {
+        union {
+            struct {FP_ x,y,z;};
+        }; // { dg-error "anonymous struct" }
+        y*rhs.z() - z*rhs.y(); // { dg-error "no member" }
+	return *this;
+    }
+    Vec& operator^(Vec& rhs) {
+        return Vec(*this)^=rhs; // { dg-message "instantiated" }
+    }
+};
+Vec<double> v(3,4,12);  // { dg-error "no matching" }
+Vec<double> V(12,4,3);  // { dg-error "no matching" }
+Vec<double> c = v^V;    // { dg-message "instantiated" }
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 161825)
+++ cp/pt.c	(working copy)
@@ -12625,7 +12625,9 @@  tsubst_copy_and_build (tree t,
       {
 	tree object;
 	tree object_type;
-	tree member;
+	tree member = TREE_OPERAND (t, 1);
+	if (!member)
+	  return error_mark_node;
 
 	object = tsubst_non_call_postfix_expression (TREE_OPERAND (t, 0),
 						     args, complain, in_decl);
@@ -12634,7 +12636,6 @@  tsubst_copy_and_build (tree t,
 	  mark_used (object);
 	object_type = TREE_TYPE (object);
 
-	member = TREE_OPERAND (t, 1);
 	if (BASELINK_P (member))
 	  member = tsubst_baselink (member,
 				    non_reference (TREE_TYPE (object)),