This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: const_cast problem?
- To: snyder at d0sgif dot fnal dot gov (scott snyder), egcs-bugs at cygnus dot com
- Subject: Re: const_cast problem?
- From: Jason Merrill <jason at cygnus dot com>
- Date: 27 Nov 1997 14:17:36 -0800
- References: <199711252318.XAA12254.cygnus.egcs.bugs@d0sgif.fnal.gov>
>>>>> 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