summaryrefslogtreecommitdiff
path: root/vcl/win/gdi/DWriteTextRenderer.cxx
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/gdi/DWriteTextRenderer.cxx
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/gdi/DWriteTextRenderer.cxx')
-rw-r--r--vcl/win/gdi/DWriteTextRenderer.cxx5
1 files changed, 4 insertions, 1 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));
}