<html>
    <head>
      <base href="https://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 --- - Better QOI for "cannot initialize a parameter of type..." error"
   href="https://llvm.org/bugs/show_bug.cgi?id=25331">25331</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Better QOI for "cannot initialize a parameter of type..." error
          </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>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jingham@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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.</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>