Boost logo

Boost :

Subject: Re: [boost] Is there interest in portable integer overflow detection, with policy based handling?
From: Robert Kawulak (robert.kawulak_at_[hidden])
Date: 2012-02-28 14:47:10


2012/2/21 Ben Robinson <cppmaven_at_[hidden]>:
> The implementation is fully portable, and it provides integer types which
> can be used like the builtin integers, except they will trigger their
> policy on an overflow.

That's great that Boost is on the way to have this facility.

> Also, this library will integrate seamlessly with the Boost Constrained
> Value Library (contributed by Robert Kawulak).

It should nicely complement the functionality of Constrained Value.
What I would be interested in is seeing some code for
constrained_int<verified_int<>> compiled to assembly with optimisation
turned on - I guess a good compiler may nicely optimise out
unnecessary checks, but I'd like to see that verified.

I've only skimmed quickly through the code - it needs polishing, but
looks promising. Some small remarks for now:
- instead of using macros for testing different types you may use test
case templates (,
- in verified_int::operator-() you don't check for overflow of -this->value_,
- I doubt that virtual inheritance of overflow_detected and
std::exception makes sense - can there be several kinds of overflow at
once, forcing multiple inheritance of the exceptions?

Best regards,

Boost list run by bdawes at, gregod at, cpdaniel at, john at