Boost logo

Boost Users :

From: Terje Slettebų (tslettebo_at_[hidden])
Date: 2003-03-22 02:58:42


>From: "klapshin" <klapshin_at_[hidden]>

> --- In Boost-Users_at_[hidden], Kevlin Henney <kevlin_at_c...>
> wrote:
> > Is the runtime behaviour correct? Have you been able to reproduce
> the
> > warning with a smaller example based just on lexical_cast?
>
> I have not tried to run program yet because of much bigger problems
> with random library -- it simply fails to compile (see my original
> post).
>
> Reproducing warning with lexical cast is straightforward:
>
> #include <boost/lexical_cast.hpp>
> #include <iostream>
> int main()
> {
> std::cout << boost::lexical_cast<int>("7") << std::endl;
> return 0;
> }
>
> reports the same warning
>
> I:\SW\EXTERNAL\BOOST_1_30_0\boost/lexical_cast.hpp(147) : warning
> C4800: 'void *' : forcing value to bool 'true' or 'false'
> (performance warning)
> I:\SW\EXTERNAL\BOOST_1_30_0\boost/lexical_cast.hpp(146) :
> while compiling class-template member function 'bool __thiscall
> boost::detail::lexical_stream<int,char *>::operator <<(char *const
> & )'
>
> Runtime behaviour of this program is correct. The warning is rather
> innocent, but annoying.
> Moreover the warning is abolutely correct -- returning stream from
> method with bool return type will convert void* to bool. Also it
> should be rather easy to fix, by explicitely casting it to bool.

This issues has also been reported on the developer list, and I've mentioned
the same possible fix there (explicit cast).

Regards,

Terje


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net