Boost logo

Boost Users :

From: Daniel Krügler (dsp_at_[hidden])
Date: 2005-08-29 01:07:25


Daniel Krügler wrote:
> The streaming inserter of Boost archive's dinkumware.hpp for
> boost::int64_t causes indefinite recursion in case of negative
> arguments. I think the following line inside the else clause should be
> changed from
>
> os << -t;
>
> to
>
> os << static_cast<boost::uint64_t>(-t);
>
> Greetings from Bremen,
>
> Daniel

I apologize for incomplete information. The streaming inserter does not
cause infinite recursion in **general** cases, but only in one special
case: If the argument equals
std::numeric_limits<boost::uint64_t>::min().

This is a special case, because in 2-complement systems (I think, that
is the only audience for that header) negating this value will return
a negative number. From a general standpoint of C++ this is one special
form of U.B., as described in section 6.2.5 of the C99 standard (I have
no older C standard available), but considering the code to be available
only for the platform target I **assume** (contradictory opinions
anywhere?) that the proposed code, which in general C++ would also cause
U.B., uses platform specific behaviour to prevent that case.

Greetinmgs from Bremen,

Daniel Krügler


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