dynamic_cast from a const class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Does the below code look like valid C++, or is it a G++ bug?  5.2.7 has

<...>
The dynamic_cast operator shall not cast away constness (5.2.11).

The other compilers I could check quickly (clang, icc, msvc) all reject the code, GCCs 3.3, 4.6, 4.7 and 4.8 accept the code.

Andrey


class A {
};

class B : public A {
};

int main() {
  A* a;
  B* b = new B();
  a = dynamic_cast<const A*>(b);
  return 0;
}




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux