http://llvm.org/bugs/show_bug.cgi?id=12463
Bug #: 12463
Summary: -Wtautological-compare and -Wstring-compare are
disabled if macro expansion is involved
Product: clang
Version: trunk
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
$ cat a.cpp
#define FOO "foo"
#define BAR "bar"
bool foo()
{
bool b;
b = FOO == BAR;
b = "foo" == "bar";
return b;
}
$ clang++ -Wall a.cpp -c
a.cpp:7:15: warning: result of comparison against a string literal is
unspecified (use strncmp instead) [-Wstring-compare]
b = "foo" == "bar";
~~~~~ ^
1 warning generated.
Line 6 should generate a warning as well. As the warning says, the result of
such a comparison is unspecified, so it is never correct, even if it comes from
a macro expansion.
--
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs