Closed Bug 1242789 Opened 8 years ago Closed 8 years ago

Allow lambdas capturing raw pointers to refcounted objects *by reference*

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(firefox47 fixed)

RESOLVED FIXED
mozilla47
Tracking Status
firefox47 --- fixed

People

(Reporter: botond, Assigned: nika)

References

Details

Attachments

(1 file)

In bug 1153304, we introduced a static analysis to prevent lambdas from capturing raw pointers to refcounted objects. 

The idea was to avoid scenarios where the the captured raw pointer outlives the function in which the lambda is created (e.g. because a copy of the lambda is stored somewhere that outlives the function).

:jgilbert pointed out in bug 1201275 comment 4 that this check doesn't have much value in the case where the raw pointer is being captured *by reference*. In such a case, the correctness of the code is already predicated on the lambda not outliving the original raw pointer variable, so forcing that variable to have type RefPtr doesn't add any safety.

I'd like to propose modifying the static analysis to allow this case. Thoughts?
Blocks: 1227224
Attachment #8711962 - Flags: review?(ehsan) → review+
https://hg.mozilla.org/mozilla-central/rev/8e3441257c01
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla47
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: