-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
| Bugzilla Link | 11277 |
| Version | unspecified |
| OS | Linux |
| Reporter | LLVM Bugzilla Contributor |
| CC | @DougGregor |
Extended Description
Consider the following simple code:
#include <vector>
typedef void* hidden_type;
int f(double d);
int main(void)
{
hidden_type w;
std::vector<hidden_type> v;
f(w);
f(v);
}This produces as output:
t.cc:11:2: error: no matching function for call to 'f'
f(w);
^
t.cc:5:5: note: candidate function not viable: cannot convert argument of
incomplete type 'hidden_type' (aka 'void *') to 'double'
int f(double d);
^
t.cc:12:2: error: no matching function for call to 'f'
f(v);
^
t.cc:5:5: note: candidate function not viable: no known conversion from
'std::vector<hidden_type>' to 'double' for 1st argument;
int f(double d);
^
Notice how I am told in the first error that 'hidden_type' is void*, but in the second case I am just given std::vector<hidden_type>.
In code I had this actually occur in, the type argument was a much more complicated template monstrosity, and in the end I had to introduce a new error into my code just to get the compiler to tell me what the 'hidden_type' actually was.
As g++ seems to not track template arguments, in this case it produces the more helpful:
t.cc:11:5: error: cannot convert ‘hidden_type {aka void*}’ to ‘double’ for argument ‘1’ to ‘int f(double)’
t.cc:12:5: error: cannot convert ‘std::vector<void*>’ to ‘double’ for argument ‘1’ to ‘int f(double)’
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillac++clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer