This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[C++ dayly bug report] const_cast to rvalue of class type
- To: egcs-bugs at egcs dot cygnus dot com, egcs at egcs dot cygnus dot com
- Subject: [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 02:28:51 +0200
- Cc: Guillaume Laurent <glaurent at worldnet dot fr>
- Organization: I.N.R.I.A Sophia-Antipolis (France)
EGCS/g++ happily accepts to const_cast to rvalues of class type.
// --- cut here ---
#include <iostream>
struct A {
A() {}
A(const A&) { std::cout << "A::A(const A&)\n"; }
};
int main()
{
A a;
const_cast<const A>(a); // ERROR
}
// --- cut here ---
The program is ill-formed according to 5.2.11.
-- Gaby