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 middle-end/83404] New: bogus stringop-overflow warning


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

            Bug ID: 83404
           Summary: bogus stringop-overflow warning
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernd.edlinger at hotmail dot de
  Target Milestone: ---

$ cat test.c
#include <string.h>
main()
{
  char x[12];
  strncpy(x, "", 12);
  strncat(x, "aa", 1);
  strncat(x, "aa", 2);
  strncat(x, "aa", 3);
}
$ gcc -Wall -W test.c
test.c: In function ‘main’:
test.c:7:3: warning: ‘strncat’ specified bound 2 equals source length
[-Wstringop-overflow=]
   strncat(x, "aa", 2);
   ^~~~~~~~~~~~~~~~~~~


The warning here is a bit surprising to me.

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