I have a block of code: struct LatLon : public Coord { std::string lat; std::string lon;
inline LatLon() : lat(""), lon("") {} }; Coord* coord; coord = new LatLon(); static_cast<const LatLon*>(coord)->lat = static_cast<const LatLon*>(other.coord)->lat; static_cast<const LatLon*>(coord)->lon = static_cast<const LatLon*>(other.coord)->lon; This should fail to compile as I casted it to a const pointer object. And it does fail with the 3.2.2 compiler. But it successfully compiles with the 4.1.2 compiler. Compiled sucessfully Red Hat Fedora Core 6: g++ --version g++ (GCC) 4.1.2 20070626 (Red Hat 4.1.2-13) Failed to compile on White Box Linux WS3: g++ --version g++ (GCC) 3.2.2 Copyright (C) 2002 Free Software Foundation, Inc. XmlInMessages.C: In copy constructor `xmlin::LocateRequestMessage::LocateRequestMessage(const xmlin::LocateRequestMessage&)': XmlInMessages.C:243: passing `const std::string' as `this' argument of ` std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' discards qualifiers XmlInMessages.C:244: passing `const std::string' as `this' argument of ` std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]' discards qualifiers make: *** [../obj/gnu/XmlInMessages.o] Error 1 -- Summary: Assignement allowed to const pointer Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: brianp at occinc dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33728