summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-11-25 11:06:00 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-11-25 14:08:20 +0100
commitb1404b5919f8c18bde715f68b229d2c030de5b2a (patch)
treed82079af2daf693364aca6c111d9dcbecbaba12c /vcl/win
parent69372bf111c0a85e754d72248bcd22b455f11938 (diff)
-Wc++11-narrowing (clang-cl)
MSVC seems not to mind, but a Windows 64-bit build with clang-cl fails with "error: non-constant-expression cannot be narrowed from type 'tools::Long' (aka 'long long') to 'LONG' (aka 'long') in initializer list". But adding explicit casts would have the downside of preventing tools like -fsanitize=implict-conversion (if we ever use that on Windows) from detecting truncation, so introduce o3tl::narrowing. Change-Id: Ia33a9ae4d8134b5ad0c8b7cf6812fbdd625ca89e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106577 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/DWriteTextRenderer.cxx5
-rw-r--r--vcl/win/gdi/winlayout.cxx7
2 files changed, 9 insertions, 3 deletions
diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx
index da8eab0e6ce0..185925ae7967 100644
--- a/vcl/win/gdi/DWriteTextRenderer.cxx
+++ b/vcl/win/gdi/DWriteTextRenderer.cxx
@@ -30,6 +30,7 @@
#include <winver.h>
#include <comphelper/windowserrorstring.hxx>
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
namespace
@@ -190,7 +191,9 @@ bool D2DWriteTextOutRenderer::Ready() const
HRESULT D2DWriteTextOutRenderer::BindDC(HDC hDC, tools::Rectangle const & rRect)
{
- RECT const rc = { rRect.Left(), rRect.Top(), rRect.Right(), rRect.Bottom() };
+ RECT const rc = {
+ o3tl::narrowing<LONG>(rRect.Left()), o3tl::narrowing<LONG>(rRect.Top()),
+ o3tl::narrowing<LONG>(rRect.Right()), o3tl::narrowing<LONG>(rRect.Bottom()) };
return CHECKHR(mpRT->BindDC(hDC, &rc));
}
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 7863a3c353d2..398196438fb7 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -21,6 +21,8 @@
#include <config_features.h>
#include <memory>
+
+#include <o3tl/safeint.hxx>
#include <osl/module.h>
#include <osl/file.h>
#include <sal/log.hxx>
@@ -594,8 +596,9 @@ void WinSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
// we are making changes to the DC, make sure we got a new one
assert(aDC->getCompatibleHDC() != hDC);
- RECT aWinRect = { aRect.Left(), aRect.Top(), aRect.Left() + aRect.GetWidth(),
- aRect.Top() + aRect.GetHeight() };
+ RECT aWinRect = { o3tl::narrowing<LONG>(aRect.Left()), o3tl::narrowing<LONG>(aRect.Top()),
+ o3tl::narrowing<LONG>(aRect.Left() + aRect.GetWidth()),
+ o3tl::narrowing<LONG>(aRect.Top() + aRect.GetHeight()) };
::FillRect(aDC->getCompatibleHDC(), &aWinRect,
static_cast<HBRUSH>(::GetStockObject(WHITE_BRUSH)));