[C++ dayly bug report] const_cast to rvalue of class type

Gabriel Dos_Reis Gabriel.Dos_Reis@sophia.inria.fr
Thu Apr 29 19:43:00 GMT 1999


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


More information about the Gcc-bugs mailing list