Closed
Bug 1344448
Opened 8 years ago
Closed 8 years ago
nsLiteralString can be reassigned
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
firefox54 | --- | affected |
People
(Reporter: bzbarsky, Assigned: away)
References
Details
I saw some code like this today during a review:
auto foo = NS_LITERAL_STRING("bar");
if (something) {
foo = NS_LITERAL_STRING("baz");
}
OK, so "auto" is evil an even though the RHS is explicitly typed as "const nsLiteralString&" it declares "foo' as "nsLiteralString" (I assume... I don't know how to check). But I'm still not thrilled that assignment works.
I'll fix this as part of bug 1344629.
> OK, so "auto" is evil an even though the RHS is explicitly typed as "const
> nsLiteralString&" it declares "foo' as "nsLiteralString" (I assume... I
> don't know how to check).
Yup.
void whatType(float f) {}
whatType(foo);
error C2664: 'void whatType(float)': cannot convert argument 1 from 'nsLiteralString' to 'float'
Assignee: nobody → dmajor
Depends on: 1344629
As part of bug 1344629 I deleted operator=.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Updated•4 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•