Open
Bug 943870
Opened 11 years ago
Updated 2 years ago
Consider removing char* casts from char16ptr_t.
Categories
(Core :: XPCOM, defect)
Tracking
()
NEW
People
(Reporter: jacek, Unassigned)
References
Details
(Whiteboard: leave open)
Attachments
(3 files, 1 obsolete file)
1019 bytes,
patch
|
Details | Diff | Splinter Review | |
4.96 KB,
text/plain
|
Details | |
4.33 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
See bug 928351 comment 36:
> + }
> + explicit operator unsigned char*() const {
> + return const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(ptr));
> + }
> + explicit operator void*() const {
These four const char*, const unsigned char*, unsigned char*, void* explicit operators are blargh. How many instances were we actually hitting where these were necessary? If it's relatively "few" I would probably go more for uglifying casts at those sites, or in some utility method in some central header that did the relevant sequence of casts instead. (This would be followup-land, to be clear.)
Comment 1•11 years ago
|
||
Based on the successful try builds, it seems that we aren't using the casts at all: https://tbpl.mozilla.org/?tree=Try&rev=e2542e8ffd65
Assignee: nobody → birunthan
Status: NEW → ASSIGNED
Attachment #8341685 -
Flags: review?(jwalden+bmo)
Reporter | ||
Comment 2•11 years ago
|
||
This code is not covered by try. It's mingw-specific.
Comment 3•11 years ago
|
||
(In reply to Jacek Caban from comment #2)
> This code is not covered by try. It's mingw-specific.
Oh, I see. I'll unassign myself then. Thanks for the info!
Status: ASSIGNED → NEW
Updated•11 years ago
|
Assignee: birunthan → nobody
Updated•11 years ago
|
Attachment #8341685 -
Attachment is obsolete: true
Attachment #8341685 -
Flags: review?(jwalden+bmo)
Comment 4•11 years ago
|
||
(In reply to Jacek Caban from comment #0)
> See bug 928351 comment 36:
>
> > + }
> > + explicit operator unsigned char*() const {
> > + return const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(ptr));
> > + }
> > + explicit operator void*() const {
>
> These four const char*, const unsigned char*, unsigned char*, void* explicit
> operators are blargh. How many instances were we actually hitting where
> these were necessary? If it's relatively "few" I would probably go more for
> uglifying casts at those sites, or in some utility method in some central
> header that did the relevant sequence of casts instead. (This would be
> followup-land, to be clear.)
So, how many of these are we hitting on mingw?
Reporter | ||
Comment 5•11 years ago
|
||
I will try to get those numbers, but this will have to wait at least until tomorrow.
Reporter | ||
Comment 6•11 years ago
|
||
I used the attached patch to count use cases of those operators. This makes GCC emit a warning for each case. There are fewer of those than I expected - only 20 for 64-bit debug build. I will attach grepped logs.
Reporter | ||
Comment 7•11 years ago
|
||
Reporter | ||
Comment 8•11 years ago
|
||
Note that this will only catch cases like (char*)str. reinterpret_casts will not emit warnings.
Updated•11 years ago
|
Attachment #8345813 -
Flags: review?(ehsan) → review+
Reporter | ||
Comment 10•11 years ago
|
||
Whiteboard: leave open
Comment 11•11 years ago
|
||
Assignee | ||
Updated•4 years ago
|
Component: String → XPCOM
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•