<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 - Type id miss match when std::any object passed to shared library on AARCH64 Linux"
   href="https://bugs.llvm.org/show_bug.cgi?id=45258">45258</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Type id miss match when std::any object passed to shared library on AARCH64 Linux
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>yschandra@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23264" name="attach_23264" title="Example implementation">attachment 23264</a> <a href="attachment.cgi?id=23264&action=edit" title="Example implementation">[details]</a></span>
Example implementation

When RTTI is disabled libc++ has a implementation of using address of static
member for each type
(<a href="https://github.com/llvm/llvm-project/blob/master/libcxx/include/any#L154-L161">https://github.com/llvm/llvm-project/blob/master/libcxx/include/any#L154-L161</a>),
this particular method fails on AARCH64 Linux (-target aarch64-linux-android)
when a std::any object passed by reference to a method in dynamic library it
raises bad_any_cast() exception even though type did not change. The same works
as expected on x86_64 Linux (-target x86_64-linux-android). Both are same
version of clang and libc++. 

This issue is seen with 9.0.0, 10.0.0rc3, trunk (11.0.0) clang & libc++. 

To demonstrate the problem I have a small example implemented which reproduces
the issue without libc++.

On aarch64-linux-android this example produces output

fallback type before calling function pointer 0x40002c3b4504
fallback type in function pointer             0xaaaacc30a5d4

On x86_64-linux-android this example produces output

fallback type before calling function pointer 0x58d4496a155c
fallback type in function pointer             0x58d4496a155c

To me it appears that on AARCH64 there are 2 instances of static member one in
shared library and one in main executable, leading to this issue.

Any help is appreciated on this.</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>