Topic: Type conversion
Author: "Ivan A. Kosarev" <ik@unicals.com>
Date: Fri, 29 May 2009 08:26:30 CST Raw View
Hi,
C++03 5.4 ("Explicit type conversion") #5 reads:
5 The conversions performed by
a const_cast (5.2.11),
a static_cast (5.2.9),
a static_cast followed by a const_cast,
a reinterpret_cast (5.2.10), or
a reinterpret_cast followed by a const_cast,
can be performed using the cast notation of explicit type
conversion.
However, given the code:
class C {
public:
operator const int* ();
};
void f(C &c) {
const_cast<int*>( static_cast<const int*>(c) ); // (1)
(int*) c; // (2)
}
both the GCC 4.2.4 and EDG FE 4.0 pass the line (1) and complain on
the line (2) about invalid cast what seems to be contradicting to the
verse cited.
Could anybody please clarify if these lines shall have the same
semantics or there are bugs in the implementations?
Thanks,
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]