Compiler printf format checking
mikael.vidstedt at oracle.com
Thu Dec 12 08:19:43 PST 2013
Doesn't that assume all places in the code want to print pointers using the same format? When I looked at this it wasn't obvious to me that that was always the case? OTOH maybe in those cases an explicit cast isn't so bad.
> On Dec 12, 2013, at 6:11, Zhengyu Gu <zhengyu.gu at oracle.com> wrote:
> We can change current PRT_FORMAT to %p to get compiler format checking to work, then replace %p with %8x or %16x in outputStream::do_vsnprintf(). I believe that some of tests do depend on the format.
>> On 12/11/2013 8:14 PM, Mikael Vidstedt wrote:
>> Are we saying the gcc format checking ignores any qualifiers on %p, yet correctly treats it as a pointer format? That is, if we use something like "%08p", will gcc still recognize that as a pointer format and look for a pointer argument (without complaining)?
>> On Dec 11, 2013, at 3:06 PM, John Rose <john.r.rose at oracle.com> wrote:
>>>> On Dec 11, 2013, at 2:41 PM, Dmitry Samersoff <dmitry.samersoff at oracle.com> wrote:
>>>> we can just use %p on all platforms
>>> That's clever.
>>> I do think we need to use an off-the-shelf static analyzer for the format strings. There is only a tiny amount of room to maneuver within the confines of the language of printf format strings.
>>> There are probably several other fiddly details like this, such as "how do I format intptr_t" and "how do I format jlong" and maybe "how do I format an oop". It may be possible to do some dodges like %p to get around those also. (The [-+#] modifiers look tantalizing to me in this regard.)
>>> — John
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the hotspot-runtime-dev