This is the mail archive of the gcc@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]

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



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



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