[Bug c++/39415] New: static_cast used as downcast can silently lose const
algrant at acm dot org
gcc-bugzilla@gcc.gnu.org
Mon Mar 9 20:03:00 GMT 2009
This is silently accepted:
struct T { };
struct T_impl: public T { };
T_impl *g(T *tp) { return static_cast<const T_impl*>(tp); }
The result type of the static_cast is pointer-to-const and should not
convert to a pointer-to-non-const. This seems to be specific to when
it is used as a downcast. Replacing the last line with
T *g(T *tp) { return static_cast<const T*>(tp); }
is faulted as expected.
--
Summary: static_cast used as downcast can silently lose const
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: algrant at acm dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39415
More information about the Gcc-bugs
mailing list