Closed
Bug 1156538
Opened 11 years ago
Closed 11 years ago
nsTArray move constructor should not be explicit
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla40
| Tracking | Status | |
|---|---|---|
| firefox40 | --- | fixed |
People
(Reporter: botond, Assigned: botond)
References
Details
Attachments
(1 file, 1 obsolete file)
The nsTArray move constructor is explicit.
This prevents returning a local variable of type nsTArray by value (using the move constructor to do so). For example:
#include "nsTArray.h"
nsTArray<int> foo() {
nsTArray<int> result;
return result;
}
produces:
error: no matching constructor for initialization of 'nsTArray<int>'
return result;
^~~~~~
(The patch in bug 982212 comment 20 did this for the 'nsTArray(nsTArray_Impl<E, Allocator>&&)' constructor. I believe it should have done so for the regular move constructor as well.)
| Assignee | ||
Comment 1•11 years ago
|
||
I should mention that the above code compiles with gcc, which appears to use the 'nsTArray(nsTArray_Impl<E, Allocator>&&)' constructor. My guess is that's a gcc bug.
| Assignee | ||
Comment 2•11 years ago
|
||
(The compiler with which it fails to compile is clang.)
| Assignee | ||
Comment 3•11 years ago
|
||
/r/7345 - Bug 1156538 - Make nsTArray's move constructor implicit. r=froydnj
Pull down this commit:
hg pull -r 04d7e84b5df0689dd410350f08e01843cd6a97ed https://reviewboard-hg.mozilla.org/gecko/
Attachment #8595032 -
Flags: review?(nfroyd)
Updated•11 years ago
|
Attachment #8595032 -
Flags: review?(nfroyd) → review+
Comment 4•11 years ago
|
||
Comment on attachment 8595032 [details]
MozReview Request: bz://1156538/botond
https://reviewboard.mozilla.org/r/7343/#review6115
Ship It!
Comment 5•11 years ago
|
||
Maybe we should consider relaxing the static analysis for move constructors, or not permitting |explicit| on move constructors, or something? (Admittedly, this does open some holes...) Could you file a followup bug for that, please?
| Assignee | ||
Comment 7•11 years ago
|
||
(In reply to Nathan Froyd [:froydnj] [:nfroyd] from comment #5)
> Maybe we should consider relaxing the static analysis for move constructors,
> or not permitting |explicit| on move constructors, or something?
> (Admittedly, this does open some holes...) Could you file a followup bug
> for that, please?
Filed bug 1156802.
Assignee: nobody → botond
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla40
| Assignee | ||
Comment 9•11 years ago
|
||
(In reply to Botond Ballo [:botond] from comment #1)
> I should mention that the above code compiles with gcc, which appears to use
> the 'nsTArray(nsTArray_Impl<E, Allocator>&&)' constructor. My guess is
> that's a gcc bug.
I filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65869 for this.
| Assignee | ||
Comment 10•11 years ago
|
||
Attachment #8595032 -
Attachment is obsolete: true
Attachment #8620098 -
Flags: review+
| Assignee | ||
Comment 11•11 years ago
|
||
You need to log in
before you can comment on or make changes to this bug.
Description
•