This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug lto/62249] New: Spurious FORTIFY_SOURCE warning with -flto, poll
- From: "zackw at panix dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 24 Aug 2014 15:51:29 +0000
- Subject: [Bug lto/62249] New: Spurious FORTIFY_SOURCE warning with -flto, poll
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62249
Bug ID: 62249
Summary: Spurious FORTIFY_SOURCE warning with -flto, poll
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: lto
Assignee: unassigned at gcc dot gnu.org
Reporter: zackw at panix dot com
Created attachment 33388
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33388&action=edit
test case (compile on recent glibc system)
Compile the attached program on a recent-glibc system with -D_FORTIFY_SOURCE=2
-O2 -flto and you get a spurious warning:
$ gcc -flto -O2 -D_FORTIFY_SOURCE=2 test.c
In function â__poll_aliasâ,
inlined from âmainâ at test.c:17:9:
/usr/include/x86_64-linux-gnu/bits/poll2.h:41:2: warning: call to
â__poll_chk_warnâ declared with attribute warning: poll called with fds buffer
too small file nfds entries
return __poll_chk (__fds, __nfds, __timeout, __bos (__fds));
$ gcc -fwhole-program -O2 -D_FORTIFY_SOURCE=2 test.c
$
Inspection of bits/poll2.h leads me to believe that the glibc folks expect this
construct ...
__fortify_function int
poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
{
if (__bos (__fds) != (__SIZE_TYPE__) -1)
{
if (! __builtin_constant_p (__nfds))
return __poll_chk (__fds, __nfds, __timeout, __bos (__fds));
else if (__bos (__fds) / sizeof (*__fds) < __nfds)
return __poll_chk_warn (__fds, __nfds, __timeout, __bos (__fds));
}
return __poll_alias (__fds, __nfds, __timeout);
}
... to have the dead arm of the inner 'if' eliminated (one of them must be
dead, because the condition is a call to __builtin_constant_p) before warnings
are issued.