Subject: Re: [boost] [new Warnings policy] MS C4180 on the Maintenance Guidelines
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-11-18 10:10:01
Paul A. Bristow wrote:
> I've tried to distill the many helpful comments on this as follows:
> ||C4800|| int' : forcing value to bool 'true' or 'false'||
> Use a bool valued expression.
> Write out expressions, for example: "value >= 0" or "ptr != 0" (Boost prefers
> clarity to curtness).
> Take care if using templates that constants are of the right type, for example
> you may need "static_cast<T>(1)".
> Or use static_cast<bool>(expression).
> Or suppress.
> ||# pragma warning(disable: 4800) // int' : forcing value to bool 'true' or
> Hope this is better.
> I note that this will mean quite a lot of work for some people as "if (ptr) ..."
> is such a common (and IMO dreadful) idiom.
> So I've left the getout clause "suppress" as a last resort.
> But this might encourage people to write new code in a nicer way.
I think the most common cause of this warning is that std::type_info::before
(which is supposed to return bool) returns int instead. Also,
doesn't suppress the warning.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk