[LLVMbugs] [Bug 9008] New: false unused variable warning when variable exclusively used within sizeof
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Jan 19 21:25:45 PST 2011
http://llvm.org/bugs/show_bug.cgi?id=9008
Summary: false unused variable warning when variable
exclusively used within sizeof
Product: clang
Version: 2.8
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: Static Analyzer
AssignedTo: kremenek at apple.com
ReportedBy: austinenglish at gmail.com
CC: llvmbugs at cs.uiuc.edu
// Compile with :
// clang -Wall -pipe -fno-strict-aliasing -Wdeclaration-after-statement
-Wstrict-prototypes -Wtype-limits -Wwrite-strings -Wpointer-arith test.c
#include <stdio.h>
static const char *blah[] = {"foo"};
#define foobar sizeof(blah)
int main(void)
{
printf("hello world, %lu", foobar);
return 0;
}
Originally noticed when compiling Wine's regedit:
clang -m32 -c -I. -I. -I../../include -I../../include -I../../include/msvcrt
-DWINE_STRICT_PROTOTYPES -DNO_LIBWINE_PORT -D_REENTRANT -fPIC -Wall -pipe
-fno-strict-aliasing -Wdeclaration-after-statement -Wstrict-prototypes
-Wtype-limits -Wwrite-strings -Wpointer-arith -g -O2 -fno-builtin -o regproc.o
regproc.c
regproc.c:40:20: warning: unused variable 'reg_class_names' [-Wunused-variable]
static const CHAR *reg_class_names[] = {
^
1 warning generated.
relevant code:
static const CHAR *reg_class_names[] = { "HKEY_LOCAL_MACHINE", "HKEY_USERS",
"HKEY_CLASSES_ROOT","HKEY_CURRENT_CONFIG", "HKEY_CURRENT_USER",
"HKEY_DYN_DATA"};
#define REG_CLASS_NUMBER (sizeof(reg_class_names) / sizeof(reg_class_names[0]))
austin at midna:~$ clang --version
clang version 2.8 (branches/release_28)
Target: x86_64-pc-linux-gnu
Thread model: posix
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list