This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: [3.2 PATCH] Fix typeid with reference types


On Tue, Mar 18, 2003 at 02:03:54PM -0500, Jason Merrill wrote:
> That patch is just an optimization.  If the testcase breaks without that
> patch, something else is probably broken.

The testcase works just fine when not optimizing. Only at -O1,
it doesn't see through the reference type.
The problem seems to be that although build_vtbl_ref_1 if (optimize)
found the VAR_DECL which initializes it and changed instance, it did
not change basetype and thus incorrect code was generated.
The following patch fixes the testcase on 3.2 branch too, though IMHO
it is better to use the same code as 3.3/trunk.

--- gcc/cp/class.c.jj	2002-11-09 12:39:51.000000000 -0500
+++ gcc/cp/class.c	2003-03-19 10:05:12.000000000 -0500
@@ -436,7 +436,13 @@ build_vtbl_ref_1 (instance, idx)
 		  if (IS_AGGR_TYPE (TREE_TYPE (init))
 		      && (TREE_CODE (init) == PARM_DECL
 			  || TREE_CODE (init) == VAR_DECL))
-		    instance = init;
+		    {
+		      instance = init;
+		      basetype = TREE_TYPE (instance);
+
+		      if (TREE_CODE (basetype) == REFERENCE_TYPE)
+			basetype = TREE_TYPE (basetype);
+		    }
 		}
 	    }
 	}


	Jakub


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