<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - Mention incomplete types in error message when unable to perform conversion"
href="http://llvm.org/bugs/show_bug.cgi?id=19845">19845</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Mention incomplete types in error message when unable to perform conversion
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Keywords</th>
<td>quality-of-implementation
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jonathan.sauer@gmx.de
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following code (rightly) fails to compile with clang r209302:
struct Foo;
/*struct Foo {
Foo(int);
};*/
static void foo(Foo);
int main()
{
foo(1);
}
This results in:
% ~/LLVM/build/Release+Asserts/bin/clang++ clang.cpp
clang.cpp:11:3: error: no matching function for call to 'foo'
foo(1);
^~~
clang.cpp:7:13: note: candidate function not viable: no known conversion from
'int' to 'Foo' for 1st argument
static void foo(Foo);
^
1 error generated.
The code fails to compile because Foo is incomplete/forward declared. As
forward declarations are commonly used in C++ to reduce dependencies, the
current error message can be confusing: "But integers *can* be implicitly
converted to Foo! Foo has an implicit conversion constructor! So why doesn't
this compile?"
I think it would be useful to mention when the type is incomplete, e.g.
clang.cpp:7:13: note: candidate function not viable: no known conversion from
'int' to incomplete 'Foo' for 1st argument
This would point the user to the cause of the error, i.e. a missing #include.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>