https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80806
Bug ID: 80806
Summary: gcc does not warn if local array is memset only
Product: gcc
Version: 5.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
gcc has warning "variable ‘c’ set but not used". However this warning is not
printed when local variable is cleared using memset, and then not used. Attempt
to compile following code using gcc 5.4.0 prints warning regarding c var, but
not regarding buf var:
#include <string.h>
void test()
{
char buf[10];
memset(buf, 0, sizeof(buf));
int c;
c = 1;
}
$ gcc -c -O3 -Wall -Wextra test.c -o test.o
test.c: In function ‘test’:
test.c:8:9: warning: variable ‘c’ set but not used [-Wunused-but-set-variable]
int c;
^