This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ dayly bug report] const_cast to rvalue of class type
- To: scherrey at proteus-tech dot com
- Subject: Re: [C++ dayly bug report] const_cast to rvalue of class type
- From: Gabriel Dos_Reis <Gabriel dot Dos_Reis at sophia dot inria dot fr>
- Date: 30 Apr 1999 04:43:08 +0200
- Cc: Gabriel Dos_Reis <Gabriel dot Dos_Reis at sophia dot inria dot fr>, egcs-bugs at egcs dot cygnus dot com, egcs at egcs dot cygnus dot com, Guillaume Laurent <glaurent at worldnet dot fr>
- Organization: I.N.R.I.A Sophia-Antipolis (France)
- References: <xajyajbkl30.fsf@korrigan.inria.fr> <37291A17.754FEA25@switchco.com>
Benjamin Scherrey <scherrey@switchco.com> writes:
| Please pardon my ignorance here but I'm not sure I understand what the
| issue is. For const_cast, the return type for a cast from anything other
| than a reference type is an rvalue.
No, you can use const_cast<T> if T is one of
- pointer type
- reference type
Any other type is forbidden.
| ... In this case I would expect your
| code to execute the default constructor then call your copy constructor.
| Your cast doesn't have any effect that I can see. Is this not the
| behaviour you're getting or anticipate?
No. const_cast<T> (value) is ill-formed when T is a class
type. Please, check the appropriate part of the standard I quoted.
-- Gaby