[LLVMbugs] [Bug 7000] New: Diagnostic for Invalid Cast should give Actual Type Name in addition to Typedef Type Name
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Apr 30 18:28:10 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7000
Summary: Diagnostic for Invalid Cast should give Actual Type
Name in addition to Typedef Type Name
Product: clang
Version: 2.7
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: me22.ca at gmail.com
CC: llvmbugs at cs.uiuc.edu
Created an attachment (id=4785)
--> (http://llvm.org/bugs/attachment.cgi?id=4785)
Source file (as pasted in description)
Compiling this bit of code:
typedef unsigned char value_type;
template <typename T>
void update_n(T *p_) {
value_type const *p = static_cast<value_type const *>(p_);
}
int main() {
char *s;
update_n(s);
}
I get the following error from clang++:
clang.cc:4:27: error: static_cast from 'char *' to 'value_type const *' is
not
allowed
value_type const *p = static_cast<value_type const *>(p_);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clang.cc:8:5: note: in instantiation of function template specialization
'update_n<char>' requested here
update_n(s);
^
While it's nice to see the clean name sometimes, in this case knowing about
"value_type" is useless in figuring out why the cast is invalid -- particularly
since it just reiterates what's clear in the caret diagnostic.
In the actual situation from which I took this test case, the value_type
typedef is something derived through a metafunction from template parameters,
so I can't just look at its definition to tell what the type is, so it'd be
much more helpful to know the expanded type. I'm sure there are plenty of
others where the typedef would be more helpful, and even this time it's nice to
know the typedef name, so it'd be great to have both. In fact, probably the
nicest I could hope for would be something like this: "static_cast from 'char*'
(T*) to 'unsigned char const*' (value_type const *) is not allowed". For
implicit casts it might be better to give the typedef names as primary and the
expanded names as parenthetical, though.
--
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