[LLVMbugs] [Bug 19845] New: Mention incomplete types in error message when unable to perform conversion

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 23 10:35:00 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19845

            Bug ID: 19845
           Summary: Mention incomplete types in error message when unable
                    to perform conversion
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: quality-of-implementation
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jonathan.sauer at gmx.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140523/da11b027/attachment.html>


More information about the llvm-bugs mailing list