[llvm-bugs] [Bug 27495] New: Wrong warning about unspecified behavior for comparison with string literal
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Apr 23 11:38:43 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27495
Bug ID: 27495
Summary: Wrong warning about unspecified behavior for
comparison with string literal
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: -New Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: cherepan at mccme.ru
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
While compiling such program:
int main()
{
"abc" == "def";
}
I get this warning:
$ clang -Wall -Wno-unused-value example.c
example.c:3:9: warning: result of comparison against a string literal is
unspecified (use strncmp instead) [-Wstring-compare]
"abc" == "def";
~~~~~ ^
1 warning generated.
The warning is wrong, this equality cannot be true.
I understand that the warning is intended to catch comparisons like "abc" ==
"abc" which indeed have an unspecified result. But the current warning is too
promiscuous.
The easy fix is to reformulate closer to "comparison with string literal is
always false or has an unspecified result".
The more thorough fix is to separately catch cases that could be proved to be
false at compile time.
gcc bug -- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70772 .
--
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/20160423/9072d77a/attachment.html>
More information about the llvm-bugs
mailing list