Hi,

2020/5/9 Sat 20:06:48 UTC+9 Ken Takata wrote:
>
> Hi John,
>
> 2020/5/9 Sat 16:30:42 UTC+9 John Marriott wrote:
>>
>> Hi All, 
>>
>> After cleaning my vim source repo and rebuilding with the brand new gcc 
>> 10.1 (mingw64), I get these warnings: 
>> <snip> 
>> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
>> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
>> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
>> -freg-struct-return main.c -o gobjnative/main.o 
>> In file included from main.c:11: 
>> main.c: In function 'early_arg_scan': 
>> vim.h:343:33: warning: 'I' flag used with '%x' gnu_scanf format 
>> [-Wformat=] 
>>    343 | # define SCANF_HEX_LONG_U "%Ix" 
>>        | ^~~~~ 
>> vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U' 
>>    343 | # define SCANF_HEX_LONG_U "%Ix" 
>>        | ^~~~~ 
>> vim.h:343:36: note: format string is defined here 
>>    343 | # define SCANF_HEX_LONG_U "%Ix" 
>>        | ^ 
>> vim.h:343:33: warning: format '%x' expects argument of type 'unsigned 
>> int *', but argument 3 has type 'long_u *' {aka 'long lo 
>> ng unsigned int *'} [-Wformat=] 
>>    343 | # define SCANF_HEX_LONG_U "%Ix" 
>>        | ^~~~~ 
>> vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U' 
>>    343 | # define SCANF_HEX_LONG_U "%Ix" 
>>        | ^~~~~ 
>> vim.h:343:36: note: format string is defined here 
>>    343 | # define SCANF_HEX_LONG_U "%Ix" 
>>        | ~~^ 
>>        | | 
>>        |                                    unsigned int * 
>>        | %Illx 
>> vim.h:344:33: warning: format '%u' expects argument of type 'unsigned 
>> int *', but argument 3 has type 'long_u *' {aka 'long lo 
>> ng unsigned int *'} [-Wformat=] 
>>    344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>>        | ^~~~~ 
>> vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U' 
>>    344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>>        | ^~~~~ 
>> vim.h:344:36: note: format string is defined here 
>>    344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>>        | ~~^ 
>>        | | 
>>        |                                    unsigned int * 
>>        | %Illu 
>>
>> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
>> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
>> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
>> -freg-struct-return dict.c -o gobjnative/dict.o 
>> In file included from dict.c:14: 
>> In function 'dictitem_copy', 
>>      inlined from 'dict_extend' at dict.c:936:9: 
>> vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '<unknown>' 
>> is out of the bounds of referenced subobject 'di_key' 
>>   with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
>> [-Warray-bounds] 
>>   1591 | #define STRCPY(d, s)     strcpy((char *)(d), (char *)(s)) 
>>        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
>> vim.h:1591:26: note: in definition of macro 'STRCPY' 
>>   1591 | #define STRCPY(d, s)     strcpy((char *)(d), (char *)(s)) 
>>        | ^~~~~~ 
>> In file included from vim.h:1815, 
>>                   from dict.c:14: 
>> dict.c: In function 'dict_extend': 
>> structs.h:1466:12: note: subobject 'di_key' declared here 
>>   1466 |     char_u di_key[1]; // key (actually longer!) 
>>        | ^~~~~~ 
>>
>> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
>> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
>> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
>> -freg-struct-return evalvars.c -o gobjnative/evalvars.o 
>> evalvars.c: In function 'lookup_scriptvar': 
>> cc1.exe: warning: function may return address of local variable 
>> [-Wreturn-local-addr] 
>> evalvars.c:2504:12: note: declared here 
>>   2504 |     char_u buffer[30]; 
>>        | ^~~~~~ 
>>
>> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
>> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
>> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
>> -freg-struct-return userfunc.c -o gobjnative/userfunc.o 
>> In file included from userfunc.c:14: 
>> In function 'cat_func_name', 
>>      inlined from 'get_user_func_name' at userfunc.c:3425:2: 
>> vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '<unknown>' 
>> is out of the bounds of referenced subobject 'uf_name 
>> ' with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
>> [-Warray-bounds] 
>>   1591 | #define STRCPY(d, s)     strcpy((char *)(d), (char *)(s)) 
>>        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
>> vim.h:1591:26: note: in definition of macro 'STRCPY' 
>>   1591 | #define STRCPY(d, s)     strcpy((char *)(d), (char *)(s)) 
>>        | ^~~~~~ 
>> In file included from vim.h:1815, 
>>                   from userfunc.c:14: 
>> userfunc.c: In function 'get_user_func_name': 
>> structs.h:1569:12: note: subobject 'uf_name' declared here 
>>   1569 |     char_u uf_name[1]; // name of function (actually longer); 
>> can 
>>        | ^~~~~~~ 
>> </snip> 
>>
>> I've had a look at the vim.h warning (the one from main.c). From what I 
>> can gather the "I" in the "%Ix" and "%Iu" scan format strings is a 
>> MS-specific thing. Anyhow, replacing the "I" with "z" in the format 
>> strings (lines 343 to 345 in vim.h) makes the warnings go away (see the 
>> attached patch). 
>>
>> Not sure about the others at the moment. 
>>
>> Cheers 
>> John 
>>
>
> Unfortunately, older MSVC (e.g. VC 2010) doesn't support "z" specifier.
> Do the warnings disappear if you change "%I" to "%I64"?
>

We used "I" specifier for very old compilers like MSVC6 which doesn't 
support "long long".
But, we dropped support for such old compilers a few years ago. So now we 
can use
"long long" and "ll" specifier. So, how about changing "%I" to "%ll"?

Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/8a52e23e-6a48-41ea-9328-1c5af64cdcc1%40googlegroups.com.

Raspunde prin e-mail lui