[LLVMbugs] [Bug 6708] New: clang should print inputs to constant expressions that cause errors
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Mar 25 16:07:25 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=6708
Summary: clang should print inputs to constant expressions that
cause errors
Product: clang
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Keywords: quality-of-implementation
Severity: enhancement
Priority: P
Component: C++
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: jyasskin at google.com
CC: chandlerc at gmail.com, llvmbugs at cs.uiuc.edu,
dgregor at apple.com
In metaprogramming, we often make assertions about constant expressions. It
would be nice if clang could explain why the constant expression had a bad
value. I don't know how to format the message I'm asking for though.
One example of the problem is below. It would be nice to see how 'expr' was
computed in the first note.
$ cat ~/tmp/test.cc
template <bool>
struct CompileAssert {
};
#define COMPILE_ASSERT(expr, msg) \
typedef ::CompileAssert<(bool(expr))> \
msg[bool(expr) ? 1 : -1]
template<typename T>
void foo(const T& t) {
COMPILE_ASSERT(
sizeof(T) > 4, T_is_too_small);
}
int main() {
foo(3);
}
$ Debug/bin/clang++ -c ~/tmp/test.cc
/Users/jyasskin/tmp/test.cc:10:5: error: array size is negative
COMPILE_ASSERT(
^~~~~~~~~~~~~~~
/Users/jyasskin/tmp/test.cc:6:11: note: instantiated from:
msg[bool(expr) ? 1 : -1]
^~~~~~~~~~~~~~~~~~~
/Users/jyasskin/tmp/test.cc:15:5: note: in instantiation of function template
specialization 'foo<int>' requested here
foo(3);
^
2 diagnostics generated.
--
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