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

            Bug ID: 97180
           Summary: warning: ‘__builtin___strncat_chk’ on strncat when it
                    is not necessary
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nils_beausse at hotmail dot com
  Target Milestone: ---

On gcc 9 and gcc 10 this code : 

  #define size 50
  char_table[size]

  strcpy(char_table, "");
  strncat(char_table, char_table2, size - 1);


will give a warning : 



In function ‘strncat’,
    inlined from ‘XXX’ at src/YYY.c:56:3:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:136:10: warning:
‘__builtin___strncat_chk’ output may be truncated copying AAA bytes from a
string of length BBB [-Wstringop-truncation]

I understand the warning but i see no reason to that in this case, it seems to
be a bug.

Reply via email to