On Tue, 16 Mar 2021 at 10:47, Rene Kita <m...@rkta.de> wrote: > > On Tue, Mar 16, 2021 at 11:26:29AM +0100, Jakub Jelinek wrote: > > On Tue, Mar 16, 2021 at 11:20:05AM +0100, Rene Kita wrote: > > > % gcc -Wall -Wpedantic main.c > > > main.c: In function 'main': > > > main.c:10:16: warning: format '%hn' expects argument of type 'short int > > > *', but argument 2 has type 'short unsigned int *' [-Wformat=] > > > 10 | printf("p: %hn\n", p); > > > | ~~^ ~ > > > | | | > > > | | short unsigned int * > > > | short int * > > > | %hn > ^^^^^ > > > > The warning for line 10 suggests to use '%hn' as format specifier which > > > is already used and the wrong one. AFAIK the correct format specifier > > > would be '%p' here. > > > > No, the warning tells you that argument for %hn should have short int * > > type, not unsigned short int *. > I understand this and I don't say the warning is wrong but the suggested > solution. I have highlighted the part of the output I'm talking about > above. If you replace the '%hn' with e.g. '%d' you get the same > suggestion: > > main.c: In function 'main': > main.c:10:15: warning: format '%d' expects argument of type 'int', but > argument 2 has type 'short unsigned int *' [-Wformat=] > 10 | printf("p: %d\n", p); > | ~^ ~ > | | | > | int short unsigned int * > | %hn > ^^^^^
This looks similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98819