Closed
Bug 695691
Opened 13 years ago
Closed 13 years ago
GCC (correctly) warns against using %lu for size_t in scanf in nsMemoryReporterManager.cpp
Categories
(Toolkit :: about:memory, defect)
Toolkit
about:memory
Tracking
()
RESOLVED
FIXED
mozilla10
People
(Reporter: justin.lebar+bug, Unassigned)
Details
(Whiteboard: [inbound])
Attachments
(1 file)
1.08 KB,
patch
|
n.nethercote
:
review+
|
Details | Diff | Splinter Review |
size_t takes %zu. Patch in a moment.
Reporter | ||
Comment 1•13 years ago
|
||
Attachment #568053 -
Flags: review?(nnethercote)
Comment 2•13 years ago
|
||
I looked into this a bit, and I don't think the 'z' length specifier is portable outside C99. While gnu-printf supports all the C99 flags, MinGW-w64 defaults to a MSVC-compatible version that includes none of them. This default can be changed by compiling with -D__USE_MINGW_ANSI_STDIO=1, but I presume that won't work for MSVC. In addition, while the 'll' specifier is part of the C++11 standard (and is the only 64-bit length specifier that -pedantic doesn't reject), MinGW-w64 won't accept it even with -std=c++0x / -std=gnu++0x, unless -D__USE_MINGW_ANSI_STDIO=1 is also defined (I think that can be considered a bug, especially since MSVC has supported it since MSVC 2005). So while you could technically use '%llu', that won't work without those compilation options. With all that being said, if you just want something that works, the I64 specifier works in both MSVC and GCC (although -pedantic rejects it). Of course, then you still have to cast to uin64_t / unsigned __int64. Reference: http://www.mail-archive.com/mingw-w64-public@lists.sourceforge.net/msg00400.html http://msdn.microsoft.com/en-us/library/tcxf1dw6%28v=VS.100%29.aspx
Reporter | ||
Comment 3•13 years ago
|
||
This code is linux-only; it's reading /proc/self/stam. If we really needed it to be portable, we could just make the variables of type long long. But does it matter?
Comment 4•13 years ago
|
||
I guess not, so long as it compiles :)
Updated•13 years ago
|
Attachment #568053 -
Flags: review?(nnethercote) → review+
Reporter | ||
Comment 5•13 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/ffbfb6a8d250
Whiteboard: [inbound]
Comment 6•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/ffbfb6a8d250
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla10
You need to log in
before you can comment on or make changes to this bug.
Description
•