Closed Bug 1470973 Opened 6 years ago Closed 6 years ago

Fix cairo-d2d-surface.cpp mingw clang compilation

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox-esr60 --- fixed
firefox63 --- fixed

People

(Reporter: jacek, Assigned: jacek)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

It fails with: 0:01.49 /mnt/build/mozilla/gecko/gfx/cairo/cairo/src/cairo-d2d-surface.cpp:2808:47: error: non-constant-expression cannot be narrowed from type 'UINT' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing] 0:01.49 cairo_rectangle_int_t surface_rect = { 0, 0, srcDesc.Width, srcDesc.Height }; 0:01.49 ^~~~~~~~~~~~~ 0:01.49 /mnt/build/mozilla/gecko/gfx/cairo/cairo/src/cairo-d2d-surface.cpp:2808:47: note: insert an explicit cast to silence this issue 0:01.49 cairo_rectangle_int_t surface_rect = { 0, 0, srcDesc.Width, srcDesc.Height }; 0:01.49 ^~~~~~~~~~~~~ 0:01.49 static_cast<int>( ) 0:01.49 /mnt/build/mozilla/gecko/gfx/cairo/cairo/src/cairo-d2d-surface.cpp:2808:62: error: non-constant-expression cannot be narrowed from type 'UINT' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing] 0:01.49 cairo_rectangle_int_t surface_rect = { 0, 0, srcDesc.Width, srcDesc.Height }; 0:01.49 ^~~~~~~~~~~~~~ 0:01.49 /mnt/build/mozilla/gecko/gfx/cairo/cairo/src/cairo-d2d-surface.cpp:2808:62: note: insert an explicit cast to silence this issue 0:01.49 cairo_rectangle_int_t surface_rect = { 0, 0, srcDesc.Width, srcDesc.Height }; 0:01.49 ^~~~~~~~~~~~~~ 0:01.49 static_cast<int>( ) 0:01.49 /mnt/build/mozilla/gecko/gfx/cairo/cairo/src/cairo-d2d-surface.cpp:3023:13: error: non-constant-expression cannot be narrowed from type 'UINT32' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing] 0:01.49 dst->rt->GetPixelSize().width, 0:01.49 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0:01.49 /mnt/build/mozilla/gecko/gfx/cairo/cairo/src/cairo-d2d-surface.cpp:3023:13: note: insert an explicit cast to silence this issue 0:01.49 dst->rt->GetPixelSize().width, 0:01.49 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0:01.49 static_cast<int>( ) 0:01.49 /mnt/build/mozilla/gecko/gfx/cairo/cairo/src/cairo-d2d-surface.cpp:3024:13: error: non-constant-expression cannot be narrowed from type 'UINT32' (aka 'unsigned int') to 'int' in initializer list [-Wc++11-narrowing] 0:01.49 dst->rt->GetPixelSize().height }; 0:01.49 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0:01.49 /mnt/build/mozilla/gecko/gfx/cairo/cairo/src/cairo-d2d-surface.cpp:3024:13: note: insert an explicit cast to silence this issue 0:01.49 dst->rt->GetPixelSize().height }; 0:01.49 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0:01.49 static_cast<int>( ) There are also some unused variables warnings that seem worth fixing.
This happens on my clang-cl as well. Surprised that it doesn't happen in CI. Maybe this warning got enabled on a more recent trunk revision than our automation has.
Comment on attachment 8987609 [details] Bug 1470973 - Fix cairo-d2d-surface.cpp mingw clang compilation Jeff's on leave, so hoping Lee can cover. [Approval Request Comment] This is one of several MinGW Build patches I'd like to land in esr60 for Tor. It will prevent them from carrying their own patches for the lifetime of esr60 and will enable us to keep the MinGW build functioning and know if/when/how it was broken by new commits into esr60. This commit affects all builds; but primarily affects compilation; not runtime. So if it breaks anything, we'd see compile-time errors.
Attachment #8987609 - Flags: review?(lsalzman)
Attachment #8987609 - Flags: review?(jmuizelaar)
Attachment #8987609 - Flags: approval-mozilla-esr60?
Comment on attachment 8987609 [details] Bug 1470973 - Fix cairo-d2d-surface.cpp mingw clang compilation https://reviewboard.mozilla.org/r/252834/#review260042 ::: gfx/cairo/cairo/src/cairo-d2d-surface.cpp:2807 (Diff revision 1) > area_to_copy.y + translation->y, > area_to_copy.width, area_to_copy.height }; > - cairo_rectangle_int_t surface_rect = { 0, 0, srcDesc.Width, srcDesc.Height }; > + cairo_rectangle_int_t surface_rect = { 0, 0, > + static_cast<int>(srcDesc.Width), > + static_cast<int>(srcDesc.Height) }; > This should be a C-style (int) cast, since this is a C file. Do not use C++ casts here. ::: gfx/cairo/cairo/src/cairo-d2d-surface.cpp:3023 (Diff revision 1) > > // Areas outside of the surface do not matter. > cairo_rectangle_int_t surface_rect = { 0, 0, > - dst->rt->GetPixelSize().width, > - dst->rt->GetPixelSize().height }; > + static_cast<int>(dst->rt->GetPixelSize().width), > + static_cast<int>(dst->rt->GetPixelSize().height) }; > cairo_region_intersect_rectangle(region, &surface_rect); This should also be a C-style (int) cast here.
Attachment #8987609 - Flags: review?(lsalzman) → review-
Comment on attachment 8987609 [details] Bug 1470973 - Fix cairo-d2d-surface.cpp mingw clang compilation https://reviewboard.mozilla.org/r/252834/#review260046 Oh, oops, just noticed that is somehow an actual C++ file inside cairo, which is odd and rare. So I guess C++ casts are okay in there.
Attachment #8987609 - Flags: review- → review+
Pushed by jacek@codeweavers.com: https://hg.mozilla.org/integration/autoland/rev/fd3d6fae1c8f Fix cairo-d2d-surface.cpp mingw clang compilation r=lsalzman
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
Comment on attachment 8987609 [details] Bug 1470973 - Fix cairo-d2d-surface.cpp mingw clang compilation Makes downstream maintenance easier for Tor. Approved for ESR 60.2.
Attachment #8987609 - Flags: approval-mozilla-esr60? → approval-mozilla-esr60+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: