[protoPATCH] "safe" numeric casts with explicit min/max
sbergman at redhat.com
Wed Feb 29 06:25:12 PST 2012
On 02/29/2012 12:13 PM, 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.
Are those "saturating" ulimit_cast a good thing, anyway? Looks like
they are only used in a handful of sc/source/filter/excel/ files.
Picking the first occurrence at random,
> return ulimit_cast< sal_uInt16 >( nValueCount, EXC_CHDATAFORMAT_MAXPOINTCOUNT );
from XclExpChSourceLink::ConvertDataSequence (xechart.cxx), where
nValueCount is a sal_uInt32 quantity -- is it OK to silently truncate
this quantity here, or does it rather indicate a conversion failure that
should be reported to the user?
(With "helpful" converters like these, I'm always worried they only
paper over actual shortcomings in the code.)
> So maybe we could selectively disable the warnings on this file
> instead? Someone knows how to do that with gcc and with MSVC?
More information about the LibreOffice