[llvm-bugs] [Bug 25331] New: Better QOI for "cannot initialize a parameter of type..." error
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Oct 27 17:59:35 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=25331
Bug ID: 25331
Summary: Better QOI for "cannot initialize a parameter of
type..." error
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: jingham at apple.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
I have one source file that knows of a type, say Derived, by forward reference
only. In that source file I pass a "Derived *" to a function that takes a
"Derived *". That works correctly as expected.
Now I change the signature of the Function to take a base class of Derived, say
Base. When I go to compile this file after the change, I get the error
message:
error: cannot initialize a parameter of type 'Base *' with an rvalue of type
'Derived *'
The solution, of course, is to include the header file that declares Derived in
my .cpp file, then it will know that Derived derives from Base.
At least for me, this is the sort of error you stare at for a while going "Of
course you can do that, Derived is derived from Base..." and it takes a while -
particularly if the file isn't one you wrote - to you realize that the current
source file WAS only using a forward reference.
However, the compiler actually knows that it only has a forward reference to
the Derived type, so it could say:
error: cannot initialize a parameter of type 'Base *' with an rvalue of type
'Derived *' which is only known as a forward reference
or something like that. If it adds that bit of information it would be
immediately obvious what the problem was.
--
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/20151028/16c3b356/attachment.html>
More information about the llvm-bugs
mailing list