http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55896
Bug #: 55896 Summary: Annoying compiler warning Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: sworddrag...@aol.com Created attachment 29097 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29097 Example code After changing a global struct to a static variable I got a compiler warning. I have analyzed this and tried to produce a minimum testcase. In the attachments is an example code and compiling it with "gcc -O3 -Wall -Wextra -o test -pedantic test.c" will result in the following warning: In file included from /usr/include/string.h:638:0, from test.c:3: In function 'strncat', inlined from 'load_app_settings' at test.c:39:10: /usr/include/x86_64-linux-gnu/bits/string3.h:150:3: warning: call to __builtin___strncat_chk might overflow destination buffer [enabled by default] Removing static from "static struct status STATUS;" solves the problem. Any random change in load_app_settings() can solve the problem too even if the change has nothing to do with the problem. For example if "strncat(content_2, content_1, w_strlen(content_1) - 1);" is changed to "strncat(content_2, content_1, w_strlen(content_1));" or " && content_1[0] == '['" is removed in the condition.