mingw64 gcc 12.1.0 warnings

52 views
Skip to first unread message

John Marriott

unread,
Jun 6, 2022, 4:15:58 PM6/6/22
to vim...@googlegroups.com
Hi All,

I just moved up to mingw64 with gcc 12.1.0 on my windows 8.1 x64 box.

I now have two warnings. The first:
<snip>
gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return -fpie -fPIE -DFEAT_GUI_MSWIN -DFEAT_CLIPBOARD ui.c -o gobjnative/ui.o
In file included from ui.c:18:
In function 'read_from_input_buf',
    inlined from 'inchar_loop' at ui.c:396:12:
vim.h:1776:37: warning: 'memmove' offset [-2147483647, -1] is out of the bounds [0, 256] of object 'inbuf' with type 'char_u[256]' {aka 'unsigned char[256]'} [-Warray-bounds]
 1776 | # define mch_memmove(to, from, len) memmove((char*)(to), (char*)(from), (size_t)(len))
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim.h:1776:37: note: in definition of macro 'mch_memmove'
 1776 | # define mch_memmove(to, from, len) memmove((char*)(to), (char*)(from), (size_t)(len))
      |                                     ^~~~~~~
ui.c: In function 'inchar_loop':
ui.c:750:17: note: 'inbuf' declared here
  750 | static char_u   inbuf[INBUFLEN + MAX_KEY_CODE_LEN];
      |                 ^~~~~
</snip>

The second:
<snip>
gcc -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return -fpie -fPIE  -c tee.c
ing: return type of 'main' is not 'int' [-Wmain]
   82 | main(int argc, char *argv[])
      | ^~~~
tee.c: In function 'main':
tee.c:86:17: warning: unused variable 'opt' [-Wunused-variable]
   86 |         int     opt;
      |                 ^~~
tee.c:122:24: warning: argument 1 range [18446744071562067968, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
  122 |         filepointers = calloc(numfiles, sizeof(FILE *));
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from tee.c:33:
d:\users\john\documents\software\mingw\mingw64\x86_64-w64-mingw32\include\malloc.h:57:17: note: in a call to allocation function 'calloc' declared here
   57 |   void *__cdecl calloc(size_t _NumOfElements,size_t _SizeOfElements);
      |                 ^~~~~~
</snip>

Cheers
John

Bram Moolenaar

unread,
Jun 6, 2022, 5:15:49 PM6/6/22
to vim...@googlegroups.com, John Marriott
No idea what's wrong here, probably nothing.

> The second:
> <snip>
> gcc -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -D__USE_MINGW_ANSI_STDIO
> -pipe -march=native -Wall -O3 -fomit-frame-pointer -freg-struct-return
> -fpie -fPIE  -c tee.c
> ing: return type of 'main' is not 'int' [-Wmain]
>    82 | main(int argc, char *argv[])
>       | ^~~~

That's easy to fix.

> tee.c: In function 'main':
> tee.c:86:17: warning: unused variable 'opt' [-Wunused-variable]
>    86 |         int     opt;
>       |                 ^~~

That's also easy.

> tee.c:122:24: warning: argument 1 range [18446744071562067968,
> 18446744073709551615] exceeds maximum object size 9223372036854775807
> [-Walloc-size-larger-than=]
>   122 |         filepointers = calloc(numfiles, sizeof(FILE *));
>       |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from tee.c:33:
> d:\users\john\documents\software\mingw\mingw64\x86_64-w64-mingw32\include\malloc.h:57:17:
> note: in a call to allocation function 'calloc' declared here
>    57 |   void *__cdecl calloc(size_t _NumOfElements,size_t
> _SizeOfElements);
>       |                 ^~~~~~
> </snip>

No idea.

--
TALL KNIGHT: We are now no longer the Knights Who Say Ni!
ONE KNIGHT: Ni!
OTHERS: Sh!
ONE KNIGHT: (whispers) Sorry.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

John Marriott

unread,
Jun 7, 2022, 4:10:25 PM6/7/22
to vim...@googlegroups.com
I don't know either.

>
>> tee.c:122:24: warning: argument 1 range [18446744071562067968,
>> 18446744073709551615] exceeds maximum object size 9223372036854775807
>> [-Walloc-size-larger-than=]
>>   122 |         filepointers = calloc(numfiles, sizeof(FILE *));
>>       |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> In file included from tee.c:33:
>> d:\users\john\documents\software\mingw\mingw64\x86_64-w64-mingw32\include\malloc.h:57:17:
>> note: in a call to allocation function 'calloc' declared here
>>    57 |   void *__cdecl calloc(size_t _NumOfElements,size_t
>> _SizeOfElements);
>>       |                 ^~~~~~
>> </snip>
> No idea.
>
The attached patch seems to fix it.

Cheers
John
tee.c.8.2.5066.patch

Bram Moolenaar

unread,
Jun 8, 2022, 8:11:37 AM6/8/22
to vim...@googlegroups.com, John Marriott
Thanks. I had to adjust the printf() to make it silent on my system.

--
TIM: That is not an ordinary rabbit ... 'tis the most foul cruel and
bad-tempered thing you ever set eyes on.
ROBIN: You tit. I soiled my armour I was so scared!

John Marriott

unread,
Jun 9, 2022, 6:03:52 PM6/9/22
to vim...@googlegroups.com


On 07-June-2022 07:15, Bram Moolenaar wrote:
The attached patch shuts gcc 12.1 up.

Cheers
John
ui.c.8.2.5073.patch

John Marriott

unread,
Jun 10, 2022, 12:10:17 AM6/10/22
to vim...@googlegroups.com

On 07-June-2022 07:15, Bram Moolenaar wrote:
This is probably a better patch.

Cheers
John
ui.c.8.2.5073.patch_v2

Bram Moolenaar

unread,
Jun 10, 2022, 9:55:43 AM6/10/22
to vim...@googlegroups.com, John Marriott
Thanks!

--
"When I die, I want a tombstone that says "GAME OVER" - Ton Richters

Bram Moolenaar

unread,
Jun 10, 2022, 9:55:44 AM6/10/22
to vim...@googlegroups.com, John Marriott
I actually liked the other one better.

--
[Another hideous roar.]
BEDEVERE: That's it!
ARTHUR: What?
BEDEVERE: It's The Legendary Black Beast of Aaaaarrrrrrggghhh!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Reply all
Reply to author
Forward
0 new messages