clang-cl warning: taking the address of a temporary in DrawTargetD2D1.cpp

RESOLVED FIXED in Firefox 51

Status

()

Core
Graphics
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: froydnj, Assigned: froydnj)

Tracking

(Blocks: 1 bug)

unspecified
mozilla51
All
Windows
Points:
---

Firefox Tracking Flags

(firefox51 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

clang-cl complains thusly:

c:/m-c/gfx/2d/DrawTargetD2D1.cpp(1435,62):  error: taking the address of a temporary object of type 'D2D1_BITMAP_PROPERTIES1' [-Waddress-of-temporary]
      mDC->CreateBitmap(mBitmap->GetPixelSize(), nullptr, 0, &D2D1::BitmapProperties1(D2D1_BITMAP_OPTIONS_TARGET, D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED)), getter_AddRefs(tmpBitmap));
                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You don't want to do this in general, because that temporary will be destroyed after the function call, which might lead to unexpected results.  I think in this case it is safe, as CreateBitmap isn't storing the pointer anywhere, but we should still fix it.
Yeah, moving the BitmapProperties1 out into a named variable will make the line shorter too.
Comment hidden (mozreview-request)

Comment 3

a year ago
mozreview-review
Comment on attachment 8785423 [details]
Bug 1298171 - store result of BitmapProperties1 in a temporary to avoid warnings;

https://reviewboard.mozilla.org/r/74630/#review72458
Attachment #8785423 - Flags: review?(jmuizelaar) → review+
Comment hidden (mozreview-request)
Assignee: nobody → nfroyd

Comment 5

a year ago
Pushed by nfroyd@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d3edbeffc36b
store result of BitmapProperties1 in a temporary to avoid warnings; r=jrmuizel

Comment 6

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/d3edbeffc36b
Status: NEW → RESOLVED
Last Resolved: a year ago
status-firefox51: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.