Re: gcc-14-1-0: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 17 Jul 2024 at 13:19, Josef Wolf <jw@xxxxxxxxxxxxx> wrote:
>
> Hallo,
>
> just upgraded my crossgcc-toolchain to gcc-1-14-0.
>
> Given this code snippet:
>
>   #define MG 32
>   static unsigned char a[MG] = {0};
>
>   void init_login (void)
>   {
>       int i;
>
>       for (i=0; i<MG; i++) {
>          a[i] = 1;
>       }
>   }
>
> IMHO, this code should not access index 32 of the array, because
> the for loop should terminate.
>
> Thus, following warning is completely unexpected to me:
>
>   m68k-unknown-elf-gcc -ansi -pedantic -Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -std=c99 -Wnull-dereference -g  -O3 -fno-toplevel-reorder  -mcpu32 -ffreestanding -c -o login.o login.c
>   login.c: In function 'init_login':
>   login.c:2909:22: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
>    2909 |                 a[i] = 1;
>         |                 ~~~~~^~~
>   login.c:2899:22: note: at offset 32 into destination object 'a' of size 32
>    2899 | static unsigned char a[MG] = {0};
>         |                      ^
>
> Opinions?

-Wstringop-overflow is broken by design.

This is one of the worst examples I've seen though.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux