On Thu, 22 Jun 2023 13:48:53 GMT, Julian Waters <jwat...@openjdk.org> wrote:

>> src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalker.cpp line 
>> 547:
>> 
>>> 545:         snprintf( s, sizeof(s),
>>> 546:             "ERROR calling GetAccessibleContextInfo; vmID = %lX, 
>>> context = %p",
>>> 547:             reinterpret_cast<unsigned long>(vmID), (void*)context );
>> 
>> do you need this cast? I checked a few compilers and passing a signed long 
>> to "%lX" was fine with them.
>
> gcc will crash with a warning about a mismatched format specifier between 
> signed and unsigned if this isn't done, unfortunately

Which gcc? This code compiles without warnings:

#include <stdio.h>
int main() {
        unsigned long i = 1;
        long j = 2;
        printf("%ld %ld %lx %lx %lu %lu\n", i, j, i, j, i, j);
        return 0;
}


# gcc -Wall -Wextra -Wformat=2 test.c
# gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/14125#discussion_r1238581381

Reply via email to