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: [C++ dayly bug report] const_cast to rvalue of class type


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


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