http://llvm.org/bugs/show_bug.cgi?id=18389
Bug ID: 18389
Summary: Unnecessary warning: "array subscript is of type
'char' [-Wchar-subscripts]" with constant char indexes
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
The following code for example generates the warning:
BackupQueries.cpp:2092:29: warning: array subscript is of type 'char'
[-Wchar-subscripts]
bool MachineReadable = opts['m'];
Because 'm' is in ASCII, and therefore a positive char value, on all platforms
that GCC and LLVM support and almost certainly on all platforms implementing
C++11, this warning seems unnecessary, and clearing it requires obfuscating the
code thus:
bool MachineReadable = opts[(unsigned char)'m'];
We could probably choose not to show this warning when the value of the index
is known by the compiler to be positive.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs