Closed Bug 1298171 Opened 8 years ago Closed 8 years ago

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

Categories

(Core :: Graphics, defect)

All
Windows
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: froydnj, Assigned: froydnj)

References

Details

Attachments

(1 file)

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 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+
Assignee: nobody → nfroyd
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
https://hg.mozilla.org/mozilla-central/rev/d3edbeffc36b
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: