This is the mail archive of the gcc-bugs@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]

Re: const_cast problem?


>>>>> scott snyder <snyder@d0sgif.fnal.gov> writes:

> int*& foo (int const *& x)
> {
>   return const_cast<int*&> (x);
> }

Thu Nov 27 00:59:46 1997  Jason Merrill  <jason@yorick.cygnus.com>

	* typeck.c (build_const_cast): Handle references here instead of
	handing off to convert_to_reference.

Index: typeck.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/cp/typeck.c,v
retrieving revision 1.413
diff -c -r1.413 typeck.c
*** typeck.c	1997/11/25 07:01:06	1.413
--- typeck.c	1997/11/27 22:11:37
***************
*** 5458,5466 ****
  	}
  
        if (comp_ptr_ttypes_const (TREE_TYPE (type), intype))
! 	return (convert_from_reference
! 		(convert_to_reference (type, expr, CONV_CONST|CONV_IMPLICIT,
! 				       LOOKUP_COMPLAIN, NULL_TREE)));
      }
    else if (TREE_CODE (type) == POINTER_TYPE
  	   && TREE_CODE (intype) == POINTER_TYPE
--- 5458,5468 ----
  	}
  
        if (comp_ptr_ttypes_const (TREE_TYPE (type), intype))
! 	{
! 	  expr = build_unary_op (ADDR_EXPR, expr, 0);
! 	  expr = build1 (NOP_EXPR, type, expr);
! 	  return convert_from_reference (expr);
! 	}
      }
    else if (TREE_CODE (type) == POINTER_TYPE
  	   && TREE_CODE (intype) == POINTER_TYPE


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