Closed
Bug 677993
Opened 14 years ago
Closed 14 years ago
GCC 4.6 Warning on 64-bit linux: "jsobjinlines.h:353:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]" (224 lines of output)
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
mozilla8
People
(Reporter: dholbert, Assigned: dholbert)
References
(Blocks 1 open bug)
Details
(Whiteboard: [build_warning])
Attachments
(2 files)
21.02 KB,
text/plain
|
Details | |
743 bytes,
patch
|
bhackett1024
:
review+
|
Details | Diff | Splinter Review |
I get 224 lines of build warning spam resulting from this warning:
> jsobjinlines.h: In member function ‘void JSObject::setArrayLength(uint32)’:
> jsobjinlines.h:353:24: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
(See attached log of the warnings.)
The code in question is:
> 350 JSObject::setArrayLength(uint32 length)
> 351 {
> 352 JS_ASSERT(isArray());
> 353 setPrivate((void*) length);
> 354 }
If we simply convert |length| to a long (or unsigned long if you like) just before the void* cast, I think that should fix this.
Assignee | ||
Comment 1•14 years ago
|
||
er, I meant s/long/size_t/ in previous comment. (dbaron tells me that "long" isn't guaranteed to be 64-bit on 64-bit systems -- e.g. on win64, a long is 32-bit -- whereas size_t is (more?) guaranteed to be the same size as a pointer.)
Tagging bhackett for review, since he added this line in bug 584917.
(Note that I'm assuming the GCC warning is innocuous -- it seems like we're using the void*-cast to just set a generic payload value, rather than actually depending on it being a sane pointer in this case.)
Assignee: general → dholbert
Status: NEW → ASSIGNED
Attachment #552166 -
Flags: review?(bhackett1024)
Comment 2•14 years ago
|
||
Comment on attachment 552166 [details] [diff] [review]
fix: add size_t cast
Yeah, this warning is innocuous. setPrivate takes a void* but can hold any word-sized payload, and setArrayLength takes a uint32 because that is the range for an array length permitted by the JS language.
Attachment #552166 -
Flags: review?(bhackett1024) → review+
Assignee | ||
Comment 3•14 years ago
|
||
Great -- thanks for the quick review!
I'll land this in the next day or so.
Assignee | ||
Updated•14 years ago
|
Blocks: buildwarning
Whiteboard: [build_warning]
Assignee | ||
Comment 4•14 years ago
|
||
Whiteboard: [build_warning] → [build_warning][inbound]
Target Milestone: --- → mozilla8
Comment 5•14 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Whiteboard: [build_warning][inbound] → [build_warning]
Comment 6•14 years ago
|
||
At risk of utter pedantry, the _u_nsigned _int_eger _p_oin_t_e_r_-sized type is uintptr_t. :-) But, come to think of it, there might actually be some crazy architecture which will notice this. I think someone filed a bug along those lines in the last few months, actually. rs=me if someone feels motivated to change this, in the absence of someone actively complaining about it.
Assignee | ||
Comment 7•14 years ago
|
||
http://stackoverflow.com/questions/1464174/size-t-vs-intptr-t says Waldo is right, & size_t isn't technically what we want here.
Pushed a followup to fix both setArrayLength() (the function touched by the earlier patch) and getArrayLength() (which also used a void*<-->size_t cast, and hence also benefits from Waldo's insight as well):
http://hg.mozilla.org/integration/mozilla-inbound/rev/88e9970b7e80
You need to log in
before you can comment on or make changes to this bug.
Description
•