summaryrefslogtreecommitdiff
path: root/basebmp
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-10-16 16:57:38 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-10-16 17:03:57 +0200
commiteec7b03faddad6ae6acf11f9ca737035722fcb65 (patch)
treedd9d443bef9b7e70202e722b46a0477f7ff2fc24 /basebmp
parent3cf557c12d27f1b2250e69a543136da098112d80 (diff)
-fsanitize=shift-exponent
Through test code added with d30f5bc3e65463f28c3087acad6f88e12d60e53b "lok::Document::paintTile: fix non-rectangular tiles wrt. transparency," CppunitTest_desktop_lib started to exhibit > basebmp/inc/metafunctions.hxx:210:26: runtime error: shift exponent 32 is too large for 32-bit type 'unsigned int' > unsigned int basebmp::shiftRight<unsigned int>(unsigned int, int) basebmp/inc/metafunctions.hxx:210:26 > basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>::operator()(unsigned int) const basebmp/inc/rgbmaskpixelformats.hxx:123:25 > basebmp::Color basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 255u, 4278190080u, 16711680u, 65280u, true> >::operator()<basebmp::PixelIterator<unsigned int> >(basebmp::PixelIterator<unsigned int> const&) const basebmp/inc/accessoradapters.hxx:115:16 > basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 4278190080u, 16711680u, 65280u, true>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 255u, 4278190080u, 16711680u, 65280u, true> >, basebmp::StdMasks>::getPixel_i(basegfx::B2IPoint const&) basebmp/source/bitmapdevice.cxx:472:20 > basebmp::BitmapDevice::getPixel(basegfx::B2IPoint const&) basebmp/source/bitmapdevice.cxx:1289:16 > basebmp::Color basebmp::GenericColorImageAccessor::operator()<vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> > >(vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> > const&) const basebmp/inc/genericcolorimageaccessor.hxx:54:18 > void vigra::copyLine<vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, basebmp::GenericColorImageAccessor, unsigned int*, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, vigra::IteratorAdaptor<vigra::Diff2DConstRowIteratorPolicy<vigra::Diff2D> >, basebmp::GenericColorImageAccessor, unsigned int*, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >) workdir/UnpackedTarball/vigra/include/vigra/copyimage.hxx:65:18 > void vigra::copyImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >) workdir/UnpackedTarball/vigra/include/vigra/copyimage.hxx:158:9 > void basebmp::scaleImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, bool) basebmp/inc/scaleimage.hxx:133:9 > void basebmp::scaleImage<vigra::Diff2D, basebmp::GenericColorImageAccessor, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(vigra::triple<vigra::Diff2D, vigra::Diff2D, basebmp::GenericColorImageAccessor> const&, vigra::triple<basebmp::PixelIterator<unsigned int>, basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > > const&, bool) basebmp/inc/scaleimage.hxx:180:5 > void basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, basebmp::StdMasks>::implDrawBitmapGeneric<basebmp::PixelIterator<unsigned int>, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > >(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::PixelIterator<unsigned int> const&, basebmp::UnaryFunctionAccessorAdapter<basebmp::StandardAccessor<unsigned int>, basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> > const&) basebmp/source/bitmapdevice.cxx:739:13 > basebmp::(anonymous namespace)::BitmapRenderer<basebmp::PixelIterator<unsigned int>, basebmp::StandardAccessor<unsigned int>, basebmp::AccessorSelector<basebmp::RGBMaskGetter<unsigned int, basebmp::Color, 16711680u, 65280u, 255u, false>, basebmp::RGBMaskSetter<unsigned int, basebmp::Color, 0u, 16711680u, 65280u, 255u, false> >, basebmp::StdMasks>::drawBitmap_i(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode) basebmp/source/bitmapdevice.cxx:827:21 > basebmp::BitmapDevice::drawBitmap(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode) basebmp/source/bitmapdevice.cxx:1562:9 > basebmp::BitmapDevice::drawBitmap(std::shared_ptr<basebmp::BitmapDevice> const&, basegfx::B2IBox const&, basegfx::B2IBox const&, basebmp::DrawMode, std::shared_ptr<basebmp::BitmapDevice> const&) basebmp/source/bitmapdevice.cxx:1574:9 > SvpSalGraphics::copyBits(SalTwoRect const&, SalGraphics*) vcl/headless/svpgdi.cxx:687:9 > SalGraphics::CopyBits(SalTwoRect const&, SalGraphics*, OutputDevice const*, OutputDevice const*) vcl/source/gdi/salgdilayout.cxx:589:9 > OutputDevice::GetBitmap(Point const&, Size const&) const vcl/source/outdev/bitmap.cxx:443:29 > OutputDevice::GetBitmapEx(Point const&, Size const&) const vcl/source/outdev/bitmap.cxx:487:25 > OutputDevice::DrawOutDev(Point const&, Size const&, Point const&, Size const&, OutputDevice const&) vcl/source/outdev/outdev.cxx:587:47 > sdr::overlay::OverlayManagerBuffered::ImpSaveBackground(vcl::Region const&, OutputDevice*) svx/source/sdr/overlay/overlaymanagerbuffered.cxx:198:17 > sdr::overlay::OverlayManagerBuffered::completeRedraw(vcl::Region const&, OutputDevice*) const svx/source/sdr/overlay/overlaymanagerbuffered.cxx:418:17 > (anonymous namespace)::RenderContextGuard::~RenderContextGuard() sw/source/core/view/viewsh.cxx:1714:21 > SwViewShell::Paint(OutputDevice&, Rectangle const&) sw/source/core/view/viewsh.cxx:1856:1 > SwCrsrShell::Paint(OutputDevice&, Rectangle const&) sw/source/core/crsr/crsrsh.cxx:1278:5 > SwViewShell::PaintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/core/view/viewsh.cxx:1901:5 > SwXTextDocument::paintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/uibase/uno/unotxdoc.cxx:3139:5 > non-virtual thunk to SwXTextDocument::paintTile(VirtualDevice&, int, int, int, int, long, long) sw/source/uibase/uno/unotxdoc.cxx:3132:23 > doc_paintTile desktop/source/lib/init.cxx:784:5 > DesktopLOKTest::testPaintTile() desktop/qa/desktop_lib/test_desktop_lib.cxx:299:5 Change-Id: Iadda5d7bb3f7f15706d16b813e11e6d145818f6c
Diffstat (limited to 'basebmp')
-rw-r--r--basebmp/inc/metafunctions.hxx12
1 files changed, 11 insertions, 1 deletions
diff --git a/basebmp/inc/metafunctions.hxx b/basebmp/inc/metafunctions.hxx
index 16ee2615f4d7..4e6efb44413f 100644
--- a/basebmp/inc/metafunctions.hxx
+++ b/basebmp/inc/metafunctions.hxx
@@ -25,6 +25,8 @@
#include <vigra/numerictraits.hxx>
#include <functional>
+#include <limits>
+#include <type_traits>
namespace basebmp
{
@@ -207,7 +209,15 @@ template< typename T > inline T shiftLeft( T v, int shift )
/// Shift right for positive shift value, and left otherwise
template< typename T > inline T shiftRight( T v, int shift )
{
- return shift > 0 ? v >> shift : v << (-shift);
+ // Avoid undefined behavior and only shift by less than the length in bits
+ // of the promoted left operand:
+ static_assert(
+ std::is_unsigned<T>::value,
+ "must be unsigned for promotedBits and the below ': 0' to be correct");
+ auto const promotedBits = std::numeric_limits<decltype(+T())>::digits;
+ return shift >= 0
+ ? shift < promotedBits ? v >> shift : 0
+ : -shift < promotedBits ? v << (-shift) : 0;
}
} // namespace basebmp