Boost logo

Boost :

Subject: Re: [boost] Is there interest in portable integer overflow detection, with policy based handling?
From: Ben Robinson (cppmaven_at_[hidden])
Date: 2012-02-22 13:43:36


On Wed, Feb 22, 2012 at 9:40 AM, Robert Ramey <ramey_at_[hidden]> wrote:

> Ben Robinson wrote:
> > It would appear there is interest in this library. Therefore, I am
> > making the full source available on GitHub here:
> >
> > https://github.com/cppmaven/VerifiedInt
> >
> > The library consists of three header files:
> >
> > verified_int.hpp (the integer class)
> > verified_int_policies.hpp (the overflow handling policies)
> > detail/verified_int_overflow_detection.hpp (the TMP overflow detection
> > routines)
> >
> > In addition, you will notice that some of the hundreds of unit tests
> > make
> > use of the metaassert.hpp capability. The VerifiedInt library
> > contains a number of static assertions. MetaAssert allows me to
> > write unit tests,
> > which will pass only if the static assertion fails instead of
> > passing. The trick is to convert what would be a compiler error into
> > a runtime
> > exception, and then detect the exception in the unit test.
>
> Note that boost testing handles this by detecting failure
> to compile as a legitmate, expecte result. That is there
> exists the concept that a test must fail to compile in order
> to be considered as passing the test.
>
> It is always possible to write a build system, which will invert the
return code from the compiler, to make non-compiling source pass the build.

My solution using metaassert does not depend in any way on the build
system, nor does it depend on any specific unit testing framework. The
solution is implemented fully in portable source code, and allows you to
unit tests failing static assertions, using which whatever build system and
unit testing framework you desire.

Thank you,

Ben Robinson

> Robert Ramey
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


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