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: [email protected]
ReportedBy: [email protected]
CC: [email protected], [email protected],
[email protected]
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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs