Subject: bin/35232: error in gcc4/gcc/cp/zypeck.c
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <henning.petersen@t-online.de>
List: netbsd-bugs
Date: 12/11/2006 06:45:00
>Number:         35232
>Category:       bin
>Synopsis:       error in gcc4/gcc/cp/zypeck.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 11 06:45:00 +0000 2006
>Originator:     Henning Petersen
>Release:        NetBSD-current
>Organization:
>Environment:
>Description:
Error in gcc_assertion.
Patch PR 30022 from gcc.gnu.org.
>How-To-Repeat:

>Fix:
Index: gnu/dist/gcc4/gcc/cp/typeck.c
===================================================================
RCS file: /cvsroot/src/gnu/dist/gcc4/gcc/cp/typeck.c,v
retrieving revision 1.1.1.4
diff -u -r1.1.1.4 typeck.c
--- gnu/dist/gcc4/gcc/cp/typeck.c	21 Oct 2006 22:48:55 -0000	1.1.1.4
+++ gnu/dist/gcc4/gcc/cp/typeck.c	11 Dec 2006 06:25:02 -0000
@@ -259,7 +259,7 @@
 	      || TREE_CODE (t1) == ENUMERAL_TYPE);
   gcc_assert (ARITHMETIC_TYPE_P (t2)
 	      || TREE_CODE (t2) == COMPLEX_TYPE
-	      || TREE_CODE (t1) == VECTOR_TYPE
+	      || TREE_CODE (t2) == VECTOR_TYPE
 	      || TREE_CODE (t2) == ENUMERAL_TYPE);
 
   /* In what follows, we slightly generalize the rules given in [expr] so
@@ -2978,17 +2978,19 @@
 	  && (code1 == INTEGER_TYPE || code1 == REAL_TYPE
 	      || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE))
 	{
+	  enum tree_code tcode0 = code0, tcode1 = code1;
+
 	  if (TREE_CODE (op1) == INTEGER_CST && integer_zerop (op1))
 	    warning (0, "division by zero in %<%E / 0%>", op0);
 	  else if (TREE_CODE (op1) == REAL_CST && real_zerop (op1))
 	    warning (0, "division by zero in %<%E / 0.%>", op0);
 
-	  if (code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
-	    code0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
-	  if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
-	    code1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
+	  if (tcode0 == COMPLEX_TYPE || tcode0 == VECTOR_TYPE)
+	    tcode0 = TREE_CODE (TREE_TYPE (TREE_TYPE (op0)));
+	  if (tcode1 == COMPLEX_TYPE || tcode1 == VECTOR_TYPE)
+	    tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
 
-	  if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE))
+	  if (!(tcode0 == INTEGER_TYPE && tcode1 == INTEGER_TYPE))
 	    resultcode = RDIV_EXPR;
 	  else
 	    /* When dividing two signed integers, we have to promote to int.