Closed
Bug 514071
Opened 15 years ago
Closed 15 years ago
warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 4 has type ‘long unsigned int’
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
FIXED
Tracking | Status | |
---|---|---|
status1.9.2 | --- | beta1-fixed |
People
(Reporter: mrbkap, Assigned: graydon)
References
Details
(Whiteboard: fixed-in-tracemonkey)
Attachments
(1 file)
9.82 KB,
patch
|
graydon
:
review+
|
Details | Diff | Splinter Review |
Normally these are pretty easy to fix, but I'm really not sure about this one the full g++ output is: jscntxt.cpp: In function ‘void DumpEvalCacheMeter(JSContext*)’: jscntxt.cpp:559: warning: format ‘%llu’ expects type ‘long long unsigned int’, but argument 4 has type ‘long unsigned int’ I think the problem is that I'm on a 64-bit machine. The actual type in question is uint64 so on a 64 bit Linux system only wants %lu and really wants %llu on a 32 bit system. This is one of those cases where I really miss C++ iostreams.
Comment 1•15 years ago
|
||
Iostreams, bah -- isn't there a new and portable %-escaped format specifier for ptrdiff_t and other standard int types? /be
Comment 2•15 years ago
|
||
You can use the horrid macros defined in inttypes, although we don't have that on Windows, I'm sure: http://www.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html
Comment 3•15 years ago
|
||
What Ted said! Shouldn't be hard, just more of the same of jsstdint.h.
Assignee | ||
Comment 4•15 years ago
|
||
Yeah. You want the string-pasted incantation "%" PRIu64. Or PRIuPTR if you're doing pointer-sized, as Brendan suggested. Either way, I'll take this, it's just janitorial. We may wind up having to duplicate platform-neutral definitions a little in nanojit's VMPI layer.
Assignee: general → graydon
Reporter | ||
Comment 5•15 years ago
|
||
This has gotten a lot worse now that jstracer.cpp is built on x64. I now get 28 of these in that file alone.
Comment 6•15 years ago
|
||
Casting the args to 'long long unsigned' is also a possibility, one that's arguably no uglier than PRIuWhatever.
Comment 7•15 years ago
|
||
(In reply to comment #6) > Casting the args to 'long long unsigned' is also a possibility, one that's > arguably no uglier than PRIuWhatever. That's been the traditional solution in js/src. Someone do something, my warning greps are non-zero which makes me itchy. /be
Comment 8•15 years ago
|
||
Comment 9•15 years ago
|
||
(In reply to comment #8) > stops gcc complaining on 32/64-bit opensuse 11 Might be a bit overkill, but .. in every place where the difference between two pointers is printed, I widened it to long long int and used %lld. This seems simpler than figuring out a type and format specifier which reliably means "machine word sized signed int" on all platforms, particularly Win64.
Comment 11•15 years ago
|
||
Luke, what do you think? Do we have to do this? Any better ideas?
Assignee | ||
Updated•15 years ago
|
Attachment #401133 -
Flags: review+
Assignee | ||
Comment 12•15 years ago
|
||
The better option is to use PRIuWhatever in our format strings, IMO. But to get those definitions right involves autoconfery as well as some fallback stuff in jsinttypes or jsstdint. I keep starting on that and then getting distracted by other work. It requires a lot of tedious fiddling across platforms.
Comment 13•15 years ago
|
||
(In reply to comment #11) > Luke, what do you think? Do we have to do this? Any better ideas? I say we let template argument deduction do the work instead. IOStreams isn't the only way to get this; assuming we don't mind converting a single "A%dC%p" formatted ::fprintf call into 4 separate ::fprintf calls (this is for debug output, right?), it would be pretty easy to throw in a few hollow templates to bring us type-inferred goodness: namespace js { template <class T1> void fprint(FILE *f, const T1 &t1) { ::fprintf(f, tl::TypeToFormatString<T1>::result, t1); } template <class T1,class T2> void fprint(FILE *f, const T1 &t1, const T2 &t2) { ::fprintf(f, tl::TypeToFormatString<T1>::result, t1); ::fprintf(f, tl::TypeToFormatString<T2>::result, t2); } ... } uint64_t l; js::fprint(f, "got: ", l); Getting formatting etc in on the game would involve further trickery, but it seems eminently doable.
Updated•15 years ago
|
Keywords: checkin-needed
Comment 14•15 years ago
|
||
Pushed to TM as 09e12b174aca.
Keywords: checkin-needed
Whiteboard: fixed-in-tracemonkey
Comment 15•15 years ago
|
||
That should be (length + 1) * sizeof(jschar), right? rs=me on followup. /be
Comment 16•15 years ago
|
||
Comment 15 was meant for bug 516458 but I dropped it here based on a commit message typo ;-). /be
Comment 17•15 years ago
|
||
http://hg.mozilla.org/mozilla-central/rev/9131d01c2d2a
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Comment 18•15 years ago
|
||
http://hg.mozilla.org/releases/mozilla-1.9.2/rev/18d5079f0127
status1.9.2:
--- → beta1-fixed
Flags: wanted1.9.2+
Assignee | ||
Updated•15 years ago
|
Flags: in-testsuite-
You need to log in
before you can comment on or make changes to this bug.
Description
•