[Bug lto/79062] -Walloca-larger-than and -Wformat-overflow warnings disabled by -flto

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue May 16 16:00:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79062

--- Comment #7 from Martin Sebor <msebor at gcc dot gnu.org> ---
It's not completely fixed yet.  The warning passes do run with LTO but LTO
still runs with warnings disabled unless they are explicitly enabled on the
command line.  -Walloca-larger-than is not in -Wall or -Wextra so it looks like
it works, but -Wformat-overflow is in -Wall and it's not issued when -Wall
alone is specified.

Richard had a suggestion for how to fix it on gcc-patches but I haven't gotten
around to looking into it yet.

$ (set -x && cat t.c && for lto in '' '-flto'; do /ssd/build/gcc-git/gcc/xgcc
-B /ssd/build/gcc-git/gcc -O2 -Wall -Walloca-larger-than=1 $lto -c t.c &&
/ssd/build/gcc-git/gcc/xgcc -B /ssd/build/gcc-git/gcc -O2 -Wall
-Walloca-larger-than=1  $lto t.o; done)
+ cat t.c
int main (void)
{
  char *d = (char*)__builtin_alloca (2);
  __builtin_sprintf (d, "%i", 123);
  __builtin_puts (d);
}
+ for lto in ''\'''\''' ''\''-flto'\'''
+ /ssd/build/gcc-git/gcc/xgcc -B /ssd/build/gcc-git/gcc -O2 -Wall
-Walloca-larger-than=1 -c t.c
t.c: In function ‘main’:
t.c:3:9: warning: argument to ‘alloca’ is too large [-Walloca-larger-than=]
   char *d = (char*)__builtin_alloca (2);
         ^
t.c:3:9: note: limit is 1 bytes, but argument is 2
t.c:4:26: warning: ‘%i’ directive writing 3 bytes into a region of size 2
[-Wformat-overflow=]
   __builtin_sprintf (d, "%i", 123);
                          ^~
t.c:4:3: note: ‘__builtin_sprintf’ output 4 bytes into a destination of size 2
   __builtin_sprintf (d, "%i", 123);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ /ssd/build/gcc-git/gcc/xgcc -B /ssd/build/gcc-git/gcc -O2 -Wall
-Walloca-larger-than=1 t.o
+ for lto in ''\'''\''' ''\''-flto'\'''
+ /ssd/build/gcc-git/gcc/xgcc -B /ssd/build/gcc-git/gcc -O2 -Wall
-Walloca-larger-than=1 -flto -c t.c
+ /ssd/build/gcc-git/gcc/xgcc -B /ssd/build/gcc-git/gcc -O2 -Wall
-Walloca-larger-than=1 -flto t.o
t.c: In function ‘main’:
t.c:3:9: warning: argument to ‘alloca’ is too large [-Walloca-larger-than=]
   char *d = (char*)__builtin_alloca (2);
         ^
t.c:3:9: note: limit is 1 bytes, but argument is 2


More information about the Gcc-bugs mailing list