<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Incorrect std::type_info comparison and hash_code for pointer to incomplete type"
   href="https://bugs.llvm.org/show_bug.cgi?id=37398">37398</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incorrect std::type_info comparison and hash_code for pointer to incomplete type
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>All Bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20275" name="attach_20275" title="Repro that gets std::type_info in different translation units and compares them.">attachment 20275</a> <a href="attachment.cgi?id=20275&action=edit" title="Repro that gets std::type_info in different translation units and compares them.">[details]</a></span>
Repro that gets std::type_info in different translation units and compares
them.

Steps to reproduce:
1. With typeid get std::type_info for a pointer to incomplete type in one
translation unit.
2. Get std::type_info for the same type in different translation unit.
3. Compare obtained type_info.
4. Compare hashes of obtained type_info.

Small repro case is attached.

Actual result:
Types are considered to be different, hash codes are different.
std::type_info::name() are equal by value, char* pointers are different.

Expected result:
Types should be equal, hash codes should be equal.

Comments:
In this case clang emits type info with internal linkage [1] which is correct
according to my understanding of Itanium C++ ABI. Also ABI documentation [2]
tells

<span class="quote">> After linking and loading, only one std::type_info structure is accessible
> via the external name defined by this ABI for any particular complete type
> symbol (see Vague Linkage). Therefore, except for direct or indirect pointers
> to incomplete types, the equality and inequality operators can be written as
> address comparisons when operating on those type_info objects: two type_info
> structures describe the same type if and only if they are the same structure
> (at the same address). However, in the case of pointer types, directly or
> indirectly pointing to incomplete class types, a more complex comparison is
> required, described below with the RTTI layout of pointer types.</span >

So to me it looks like libc++ bug.

[1]
<a href="https://github.com/llvm-mirror/clang/blob/6a37651bb30339e60ea617d510b4703bcd2e89e8/lib/CodeGen/ItaniumCXXABI.cpp#L3013-L3023">https://github.com/llvm-mirror/clang/blob/6a37651bb30339e60ea617d510b4703bcd2e89e8/lib/CodeGen/ItaniumCXXABI.cpp#L3013-L3023</a>
[2] <a href="http://refspecs.linuxbase.org/cxxabi-1.83.html#rtti">http://refspecs.linuxbase.org/cxxabi-1.83.html#rtti</a></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>