[Bug c/49120] New: bogus "value computed is not used" warning (variable-length array in compound statement)
kari.nurmela at stonesoft dot com
gcc-bugzilla@gcc.gnu.org
Mon May 23 10:49:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49120
Summary: bogus "value computed is not used" warning
(variable-length array in compound statement)
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: kari.nurmela@stonesoft.com
When declaring a variable-length array in the beginning of a compound
statement, so that the length expression contains at least one operator,
the warning "value computed is not used" is incorrectly given for the computed
length of the array (with -Wall). For example:
~$ cat kok1.c
int main(void)
{
int foo = 1;
({
char bar[foo + 1]; /* <==== */
bar[0] = 0;
});
return 0;
}
~$ gcc-4.5 -Wall kok1.c -o kok1
kok1.c: In function ‘main’:
kok1.c:5:22: warning: value computed is not used
~$ gcc-4.5 --version
gcc-4.5 (Ubuntu/Linaro 4.5.1-7ubuntu2) 4.5.1
...
If the compound statement is replaced with a block in this example, the warning
goes away:
~$ cat kok2.c
int main(void)
{
int foo = 1;
{
char bar[foo + 1];
bar[0] = 0;
}
return 0;
}
~$ gcc-4.5 -Wall kok2.c -o kok2
~$
In gcc 4.4 the bogus warning does not appear:
~$ gcc-4.4 -Wall kok1.c -o kok1
~$ gcc-4.4 --version
gcc-4.4 (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5
...
More information about the Gcc-bugs
mailing list