PATCH: dynamic_cast failure

Nathan Sidwell nathan@acm.org
Mon Jan 11 03:18:00 GMT 1999


Hi,
this is a patch for the bug report I filed about dynamic_cast<><T::m>
failing ( http://www.cygnus.com/ml/egcs-bugs/1999-Jan/0187.html ).
Looking at the compiler's behaviour and the CD2, I came to the
conclusion that it is a bug.

The problem was that build_dynamic_cast_1 was failing to resolve an
OFFSET_REF expr node, before starting its work. I inserted code
to do this, just as build_new_op (call.c) does with its args.

I hope this is satisfactory.

nathan
-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light      
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk
egcs/gcc/cp/ChangeLog:
Mon Jan 11 10:26:45 GMT 1999  Nathan Sidwell  <nathan@acm.org>

	* rtti.c (build_dynamic_cast_1): Resolve OFFSET_REF exprs.

Index: egcs/gcc/cp/rtti.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/rtti.c,v
retrieving revision 1.25
diff -c -3 -p -r1.25 rtti.c
*** rtti.c	1998/12/16 21:16:06	1.25
--- rtti.c	1999/01/11 10:26:04
*************** build_dynamic_cast_1 (type, expr)
*** 456,466 ****
       tree type, expr;
  {
    enum tree_code tc = TREE_CODE (type);
!   tree exprtype = TREE_TYPE (expr);
    enum tree_code ec;
    tree dcast_fn;
    tree old_expr = expr;
  
    assert (exprtype != NULL_TREE);
    ec = TREE_CODE (exprtype);
  
--- 456,470 ----
       tree type, expr;
  {
    enum tree_code tc = TREE_CODE (type);
!   tree exprtype;
    enum tree_code ec;
    tree dcast_fn;
    tree old_expr = expr;
  
+   if (TREE_CODE (expr) == OFFSET_REF)
+     expr = resolve_offset_ref (expr);
+   
+   exprtype = TREE_TYPE (expr);
    assert (exprtype != NULL_TREE);
    ec = TREE_CODE (exprtype);
  


More information about the Gcc-patches mailing list