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 tree-optimization/81401] False positive sprintf warning at O2 (-Wformat-overflow)


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

Jörg Richter <joerg.richter@pdv-fs.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joerg.richter@pdv-fs.de

--- Comment #2 from Jörg Richter <joerg.richter@pdv-fs.de> ---
See also:

#include <stdio.h>
void foo()
{
  char buf[2];
  for( int i = 0; i < 10; ++i )
    sprintf( buf, "%d", i );
}


t.cc: In function 'void foo()':
t.cc:2:6: warning: 'sprintf' may write a terminating nul past the end of the
destination [-Wformat-overflow=]
 void foo()
      ^~~
t.cc:6:12: note: 'sprintf' output between 2 and 3 bytes into a destination of
size 2
     sprintf( buf, "%d", i );
     ~~~~~~~^~~~~~~~~~~~~~~~

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