This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/55892] Bogus compiler warning


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55892

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-01-07 07:34:25 UTC ---
First off you also need -D_FORTIFY_SOURCE and a newish glibc headers.  Second I
think this warning is correct.
Take a line which is 16 characters long.
The first time at beginning of the loop, limit: 8; readlimit: 8.

The next time, limit:0 readlimit: 0.
The next time limit: (unsigned long)(-8) readlimit: INT32_MAX
Warn because readlimit > 1024.

The reason why the first call to fgetsl does not warn is because it does not
get inlined as it is not hot.
The second is also the same reason as the first but also the code for fgets
cannot figure out the size of the variable, buffer.
The last has the same issue as second minus the inline issue.

The trunk gives a very good warning message of the point of the inline function
happens too:
In file included from /usr/include/stdio.h:910:0,
                 from t67.c:2:
In function âfgetsâ,
    inlined from âfgetsl.constprop.0â at t67.c:17:11,
    inlined from âmainâ at t67.c:33:14:
/usr/include/bits/stdio2.h:253:2: warning: call to â__fgets_chk_warnâ declared
with attribute warning: fgets called with bigger size than length of
destination buffer [enabled by default]
  return __fgets_chk_warn (__s, __bos (__s), __n, __stream);
  ^


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]