[LLVMbugs] [Bug 10211] New: False positives with -Wconstant-logical-operand in template code
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jun 27 19:27:17 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=10211
Summary: False positives with -Wconstant-logical-operand in
template code
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: rjmccall at apple.com
CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com
-Wconstant-logical-operand warns about code where the constant argument was
instantiated from a template. This is idiomatically acceptable code. It comes
up a lot in e.g. Eigen:
http://eigen.tuxfamily.org/index.php?title=Main_Page
Anyone verifying this should probably do a test compile with some Eigen files,
e.g. 2.0.15's test/geometry.cpp [note: clang -I.. -D test_geometry], but here's
a short reduction of a few cases we should get:
template <class T> class A {
unsigned count() { return 0; }
bool test1() { return (count() && int(T::SomeBit)); }
enum {
SomeBit = T::SomeBit
};
bool test2() { return (count() && int(SomeBit)); }
};
struct B { enum { SomeBit = true }; };
template class A<B>;
The warning doesn't trigger here without the function-style casts.
--
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.
More information about the llvm-bugs
mailing list