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


Hi,

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 (http://www.boost.org/doc/libs/1_49_0/libs/test/doc/html/utf/user-guide/test-organization/auto-test-case-template.html),
- 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,
Robert


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk