Closed Bug 1214037 Opened 9 years ago Closed 9 years ago

MOZ_MUST_USE treats expressions evaluating to lvalue references as MUST_USE

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(firefox44 fixed)

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: nika, Assigned: nika)

References

Details

Attachments

(1 file, 1 obsolete file)

This means that we have some annoying effects, such as making `a = b` where the type of `a` is MOZ_MUST_USE complain about an unused value (as the assignment expression returns an lvalue reference to the variable).

Another option would be to instead special-case the assignment operator.
Assignee: nobody → michael
Comment on attachment 8673469 [details] [diff] [review]
Don't consider lvalue references to MOZ_MUST_USE types as MOZ_MUST_USE

Review of attachment 8673469 [details] [diff] [review]:
-----------------------------------------------------------------

I think this is a quirk of built-in operator=(), and it's definitely the wrong thing to white-list this for types such as already_AddRefed.  I'd prefer if you special case operator=() assuming that is the only thing that blows up, and Seth's try push seems to suggest that.
Attachment #8673469 - Flags: review?(ehsan) → review-
Comment on attachment 8673817 [details] [diff] [review]
Don't consider the result of an assignment expression MOZ_MUST_USE

Review of attachment 8673817 [details] [diff] [review]:
-----------------------------------------------------------------

Great, thanks a lot!
Attachment #8673817 - Flags: review?(ehsan) → review+
https://hg.mozilla.org/mozilla-central/rev/ab276d264008
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: