From: John Maddock (john_at_[hidden])
Date: 2007-12-15 07:26:37


Richard Webb wrote:
>> JOAQUIN LOPEZ MU?Z <joaquin <at> tid.es> writes:
>>
>>> I'm able to reproduce the behavior you describe and don't
>>> have any explanation for it either. But note one thing: the warnings
>>> I've got in the second scenario are all C4267 (conversion from
>>> size_t to const unsigned int, possible loss of data), which you
>>> are not explicitly silencing. If you add the corersponding pragma
>>> warning(disable: 4267) at boost/math/policies/error_handling.hpp,
>>> compile is clean then in the second scenario as well.
>>>
>>> Just my 2 cents,
>>>
>>> Joaquín M López Muñoz
>>> Telefónica, Investigación y Desarrollo
>>
>> I get the same as Joaquín, though only if i compile with the "detect
>> 64-bit portability issues" option turned on.
>>
>> In case it's of any interest, i notice that adding a
>>
>> boost::format formatter("%d");
>> formatter % 42;
>>
>> into the second case causes a bunch of the warnings to disappear,
>> and a
>>
>> boost\spirit\utility\impl\chset\range_run.ipp(69) : warning C4267:
>> '=' : conversion from 'size_t' to 'unsigned int', possible loss of
>> data
>>
>> to appear instead.

This is indeed weird, and I've finally tracked down the cause: it's nothing
to do with Spirit and everything to do with Microsoft.

If you pass a pair of std::size_t's to std::min or std::max then:

* You get no warning if the min/max<unsigned> templates haven't been
instantiated yet.
* A warning if some other code has already instantiated
std::min/max<unsigned>.

Truely weird and very annoying indeed !

I'll add some #pragma's to Boost.Format to reduce the warning noise:
otherwise the instantiation stack trace is so verbose you miss any important
warnings.

Sorry for the noise, John.