[range] From 1.33.0 gives new warning vs 1.32

I had some code that with 1.32 compiled fine when compiled with warnings as errors, but now with 1.33 I get: cc1plus: warnings being treated as errors boost_1_33_0_gcc_3.2.3/include/boost-1_33/boost/range/detail/implementation_help.hpp: In function `Char* boost::range_detail::str_end(Char*) [with Char = char]': boost_1_33_0_gcc_3.2.3/include/boost-1_33/boost/range/end.hpp:96: instantiated from here boost_1_33_0_gcc_3.2.3/include/boost-1_33/boost/range/detail/implementation_help.hpp:57: warning: cast from `const char*' to `char*' discards qualifiers from pointer target type boost_1_33_0_gcc_3.2.3/include/boost-1_33/boost/range/detail/implementation_help.hpp: In function `Char* boost::range_detail::str_end(Char*) [with Char = wchar_t]': boost_1_33_0_gcc_3.2.3/include/boost-1_33/boost/range/end.hpp:101: instantiated from here boost_1_33_0_gcc_3.2.3/include/boost-1_33/boost/range/detail/implementation_help.hpp:57: warning: cast from `const wchar_t*' to `wchar_t*' discards qualifiers from pointer target type Compiled with gcc 3.2.3 under Linux, perhaps something like this is needed? Thanks Kevin --- boost_1_33_0/boost/range/detail/implementation_help.hpp 2005-05-05 13:58:51.000000000 +0100 +++ boost_1_33_0_gcc_3.2.3/include/boost-1_33/boost/range/detail/implementation_help.hpp 2005-08-15 11:33:59.000000000 +0100 @@ -54,7 +54,7 @@ template< class Char > inline Char* str_end( Char* s ) { - return (Char*)str_end( s, s ); + return const_cast<Char*>(str_end( s, s )); } template< class T, std::size_t sz > -- | Kevin Wheatley, Cinesite (Europe) Ltd | Nobody thinks this | | Senior Technology | My employer for certain | | And Network Systems Architect | Not even myself |

"Kevin Wheatley" <hxpro@cinesite.co.uk> wrote in message news:4300715B.ED49E94C@cinesite.co.uk...
I had some code that with 1.32 compiled fine when compiled with warnings as errors, but now with 1.33 I get:
Compiled with gcc 3.2.3 under Linux,
perhaps something like this is needed?
template< class Char > inline Char* str_end( Char* s ) { - return (Char*)str_end( s, s ); + return const_cast<Char*>(str_end( s, s ));
what's the difference? A c-style cast is also a const-cast. -Thorsten

On 8/15/05, Thorsten Ottosen <nesotto@cs.aau.dk> wrote:
"Kevin Wheatley" <hxpro@cinesite.co.uk> wrote in message news:4300715B.ED49E94C@cinesite.co.uk...
I had some code that with 1.32 compiled fine when compiled with warnings as errors, but now with 1.33 I get:
Compiled with gcc 3.2.3 under Linux,
perhaps something like this is needed?
template< class Char > inline Char* str_end( Char* s ) { - return (Char*)str_end( s, s ); + return const_cast<Char*>(str_end( s, s ));
what's the difference? A c-style cast is also a const-cast.
Probably the difference is in the compiler, since if it warns that a const_cast is discarding a qualifier would be useless. But would be a somewhat valuable warning in a c-style cast. Although in my g++(3.3.4) it doesnt warn anything in a c-style cast...
-Thorsten
-- Felipe Magno de Almeida Developer from synergy and Computer Science student from State University of Campinas(UNICAMP). Unicamp: http://www.ic.unicamp.br Synergy: http://www.synergy.com.br "There is no dark side of the moon really. Matter of fact it's all dark."

Hi Thorsten I must say that I agree with Kevin (and the gcc compiler) here. A C-style cast is not only a const cast; it is a everything-cast... if the only purpose is to cast away const, be clear and use a const cast. I can see no compelling reason (except laziness) not to. /Peter
"Kevin Wheatley" <hxpro@cinesite.co.uk> wrote in message news:4300715B.ED49E94C@cinesite.co.uk...
I had some code that with 1.32 compiled fine when compiled with warnings as errors, but now with 1.33 I get:
Compiled with gcc 3.2.3 under Linux,
perhaps something like this is needed?
template< class Char > inline Char* str_end( Char* s ) { - return (Char*)str_end( s, s ); + return const_cast<Char*>(str_end( s, s ));
what's the difference? A c-style cast is also a const-cast.
-Thorsten
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

"Peter Koch Larsen" <pkl@mailme.dk> wrote in message news:12321.62.79.147.244.1124140212.squirrel@62.79.147.244...
Hi Thorsten
I must say that I agree with Kevin (and the gcc compiler) here. A C-style cast is not only a const cast; it is a everything-cast...
indeed.
if the only purpose is to cast away const, be clear and use a const cast. I can see no compelling reason (except laziness) not to.
well, I'm pretty lazy :-) I can't remember exactly why I did not use a const_cast...perhaps because the current cast was more portable. somehow. -Thorsten

Thorsten Ottosen wrote:
well, I'm pretty lazy :-)
I can't remember exactly why I did not use a const_cast...perhaps because the current cast was more portable. somehow.
in my absence, it looks like others have said what I would have, basically its a case of say what you mean and the compiler doesn't issue the warning, I havn't checked on anything else compiler wise so far as I left my machines building the rest of our in house system overnight so can't help with other compilers at the moment. If you have to use the C style cast it must be in a BOOST_WORKAROUND situation rather than the normal case. Kevin -- | Kevin Wheatley, Cinesite (Europe) Ltd | Nobody thinks this | | Senior Technology | My employer for certain | | And Network Systems Architect | Not even myself |
participants (4)
-
Felipe Magno de Almeida
-
Kevin Wheatley
-
Peter Koch Larsen
-
Thorsten Ottosen