[LLVMbugs] [Bug 18389] New: Unnecessary warning: "array subscript is of type 'char' [-Wchar-subscripts]" with constant char indexes
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Sun Jan 5 05:45:33 PST 2014
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: unassignedclangbugs at nondot.org
Reporter: chris+llvm.org at qwirx.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140105/bbc0061d/attachment.html>
More information about the llvm-bugs
mailing list