[protoPATCH] "safe" numeric casts with explicit min/max

Kohei Yoshida kohei.yoshida at suse.com
Wed Feb 29 07:20:05 PST 2012


On Wed, 2012-02-29 at 11:50 +0000, Caolán McNamara wrote:
> On Wed, 2012-02-29 at 12:13 +0100, Lionel Elie Mamane wrote:
> > Background: we have in sc/source/filter/inc/ftools.hxx supposedly
> > "safe" casts that are (according to the Doxygen documentation)
> > supposed to be safer than just static_cast. As fdo#39589 uncovered,
> > they are actually so buggy as to be *less* safe.
> > 
> > Back in November, I wrote a prototype _actually_ safe versions, but
> > got sidetracked and forgot about them. I'm unearthing them again now,
> > attached.
> 
> It might be a little orthogonal to just the cast issue, but I wonder if 
> 
> Cert's IntegerLib or SafeInt (http://safeint.codeplex.com/) or somesuch
> (https://bugzilla.mozilla.org/show_bug.cgi?id=555798) covers the same
> ground and is license-suitable as a drop in ?

Yup.  I've come across SafeInt as well while I was searching.

Boost also has numeric_cast as well.

http://www.boost.org/doc/libs/1_32_0/libs/numeric/conversion/doc/numeric_cast.html

Kohei

-- 
Kohei Yoshida, LibreOffice hacker, Calc



More information about the LibreOffice mailing list