http://llvm.org/bugs/show_bug.cgi?id=17900
Bug ID: 17900
Summary: Comparison against functions is almost always
erroneous, should warn
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Consider this code:
#include <strings.h>
int indx;
int isIndxZero()
{
return index == 0;
}
Here the user has mistakenly written “indx” as “index“, which happens to be a
POSIX.1 function. In this comparison, index decays to a pointer-to-function,
is then compared to zero, which becomes interpreted as the null pointer
constant.
As the address of a callable function, index would *never* be null, so at the
very least, this is a comparison that is likely always false.
It would be nice if at the very least we could warn that the comparison is
false, or better yet, warn about comparing a function with an integer.
Also, if as a result we ended up warning for &indx == 0, that'd be great too,
since that too is always false.
--
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