Closed
Bug 113733
Opened 23 years ago
Closed 21 years ago
nsXPIDLCString doesn't have an assignment operator
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: bbaetz, Assigned: jag+mozilla)
References
Details
Attachments
(1 file, 4 obsolete files)
3.14 KB,
patch
|
dwitte
:
review+
jag+mozilla
:
superreview+
|
Details | Diff | Splinter Review |
See netwerk/protocol/http/src/nsHttpChannel.cpp:149, which warns:
warning: using synthesized `nsXPIDLCString &nsXPIDLCString::operator= (const
nsXPIDLCString &)' for copy assignment where cfront would use `nsXPIDLCString
&nsXPIDLCString::operator= (const nsACString &)'
This warning is correct; XPIDLCString's do not have an assignment operator, and
that line will tirgger incorrect behaviour (if not now, then definately once
sharing happens)
nsSharableCString does have an operator=(nsACString&), but stroustrup 12.2.3
says: ".. assignment operators are not inherited". This makes sense, for the
same reason that constructors aren't inherited.
The other string classes probably need checking, too
Assignee | ||
Comment 1•23 years ago
|
||
Assignee | ||
Comment 2•23 years ago
|
||
dbaron: assuming that a generated operator= will do a bitwise copy, that would
rather mess with the refcounting, right? Could that be the cause of some of the
problems we've been (and still are?) seeing with that?
Assignee | ||
Comment 3•23 years ago
|
||
And as bbaetz just pointed out, we should probably copy this in
nsSharableString.
Comment 4•23 years ago
|
||
Comment on attachment 67422 [details] [diff] [review]
Let it have operator=
sure. if jag sez so :)
sr=alecf
Attachment #67422 -
Flags: superreview+
Reporter | ||
Comment 5•23 years ago
|
||
Attachment #67422 -
Attachment is obsolete: true
Comment on attachment 69627 [details] [diff] [review]
sharable string too
r=dbaron, although I wonder if we really want the latter two (|const
char_type*| and |char_type|) on the XPIDL strings.
Attachment #69627 -
Flags: review+
Assignee | ||
Comment 7•23 years ago
|
||
I agree with dbaron, let's leave out the |const CharT*| and |CharT| operator=.
Comment 8•22 years ago
|
||
giving up ancient string bugs to the new string owner. jag, you'll want to sort
through these and see which ones still apply and go with or against the
direction in which you intend strings evolve
Assignee: scc → jaggernaut
Comment 9•21 years ago
|
||
It looks like bug 122892 is still waiting on this fix, so as far as I can tell
it'd still be nice to get this in (please correct me if I'm wrong).
I've updated the patch to trunk, but in addition I had to remove the |const
promise_type&| copy constructor since |promise_type| no longer exists.
Attachment #69627 -
Attachment is obsolete: true
Comment 10•21 years ago
|
||
Comment on attachment 127222 [details] [diff] [review]
update to trunk
dbaron, mind taking a look? (I'd like to hold off on requesting sr=jag until
the patch has r+).
thanks!
Attachment #127222 -
Flags: review?(dbaron)
Comment on attachment 127222 [details] [diff] [review]
update to trunk
Some of the comments seem a bit confused -- stating the reason in two different
ways. Also, why do we need two versions -- isn't the |operator=(const
abstract_string_type&)| sufficient?
Comment 12•21 years ago
|
||
I'm not sure - XPIDLString/SharableString have had an |operator=(const
abstract_string_type&)| since this bug was filed, but this warning still exists.
I'm not sure why the compiler would synthesize |operator=(const
nsXPIDLCString&)| when it has the former available.
Any idea what's going on here?
Reporter | ||
Comment 13•21 years ago
|
||
dwitte: operator= isn't inherited. See my original comment #0.
Comment 14•21 years ago
|
||
Oh, wait - no, I can see why we'd need |operator=(const self_type&)|. I presume
that declaring it private and leaving it unimplemented would break; since the
compiler wouldn't know to fall back on the provided |operator=(const
abstract_string_type&)|. So, isn't providing the self_type operator on
XPIDLString/SharableString the right thing to do here?
(just saw your comment bbaetz... I understand now ;)
Reporter | ||
Comment 15•21 years ago
|
||
dbaron: The issue is that the compiler synthesises a |self_type&
operator=(self_type&)|. Its then the best match to use.
I can't find my copy of the c++ std, but in the draft at
http://www.csci.csusb.edu/dick/c++std/cd2/over.html, see the example at 13.5.3/2
Updated•21 years ago
|
Attachment #127222 -
Flags: review?(dbaron)
Comment 16•21 years ago
|
||
Attachment #127222 -
Attachment is obsolete: true
Comment 17•21 years ago
|
||
Comment on attachment 127348 [details] [diff] [review]
fix comments
same thing as before, but with consistent comments.
Attachment #127348 -
Flags: review?(dbaron)
Comment on attachment 127348 [details] [diff] [review]
fix comments
r=dbaron if you add a comment before all the |const self_type&| versions that
says "// prevent the compiler from synthesizing an operator=".
(I was thinking that the compiler would only synthesize if none were provided
-- like constructors -- but it's clear (from C++ 12.8 clauses 9 and 10) that
I'm wrong.)
Attachment #127348 -
Flags: review?(dbaron) → review+
Comment 19•21 years ago
|
||
Attachment #127348 -
Attachment is obsolete: true
Comment 20•21 years ago
|
||
Comment on attachment 127390 [details] [diff] [review]
fix comments v2
carrying over r=dbaron.
Attachment #127390 -
Flags: superreview?(jaggernaut)
Attachment #127390 -
Flags: review+
Assignee | ||
Comment 21•21 years ago
|
||
Comment on attachment 127390 [details] [diff] [review]
fix comments v2
Though you're technically preventing the compiler from synthesizing the copy
operator= (though I think we usually only use the word "prevent" when it's in a
private section with no implementation), what you're really doing here is
something like "// providing copy operator= since the synthesized one doesn't
do the right thing", though really that should just be implied and no comment
should be needed. See e.g. nsAString.h's operator= comment.
Attachment #127390 -
Flags: superreview?(jaggernaut) → superreview+
Comment 22•21 years ago
|
||
Checked in, with comments stolen from nsAString.h.
Status: NEW → RESOLVED
Closed: 21 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
•