[Bug lto/78768] New: -Walloca-larger-than and -Wformat-length warnings disabled by -flto
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Dec 10 22:48:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78768
Bug ID: 78768
Summary: -Walloca-larger-than and -Wformat-length warnings
disabled by -flto
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The -Walloca-larger-than and -Wformat-length options don't work with -flto.
When compiling without -flto, GCC issues the two warnings for the following
program as expected. When -flto is used, no warnings are issued.
$ (set -x && cat a.c && for o in -fno-lto -flto; do /build/gcc-svn/gcc/xgcc -B
/build/gcc-svn/gcc -O2 -Walloca-larger-than=100 -Wformat-length $o a.c; done)
+ cat a.c
char d[1];
int main (int argc, char *argv[])
{
void *p = __builtin_alloca (1234);
__builtin_sprintf (d, "%lx", (long)p);
}
+ for o in -fno-lto -flto
+ /build/gcc-svn/gcc/xgcc -B /build/gcc-svn/gcc -O2 -Walloca-larger-than=100
-Wformat-length -fno-lto a.c
a.c: In function ‘main’:
a.c:5:9: warning: argument to ‘alloca’ is too large [-Walloca-larger-than=]
void *p = __builtin_alloca (1234);
^
a.c:5:9: note: limit is 100 bytes, but argument is 1234
a.c:7:29: warning: writing a terminating nul past the end of the destination
[-Wformat-length=]
__builtin_sprintf (d, "%lx", (long)p);
~~~^
a.c:7:3: note: format output between 2 and 17 bytes into a destination of size
1
__builtin_sprintf (d, "%lx", (long)p);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ for o in -fno-lto -flto
+ /build/gcc-svn/gcc/xgcc -B /build/gcc-svn/gcc -O2 -Walloca-larger-than=100
-Wformat-length -flto a.c
More information about the Gcc-bugs
mailing list