<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 - Code for virtual function not generated"
   href="https://bugs.llvm.org/show_bug.cgi?id=45953">45953</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Code for virtual function not generated
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>C++17
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23496" name="attach_23496" title="Test code">attachment 23496</a> <a href="attachment.cgi?id=23496&action=edit" title="Test code">[details]</a></span>
Test code

For the attached C++17 code involving Boost.Beast, clang++ gives an "undefined
symbol" error (full message below). It appears that the code for the function
"boost::beast::stable_async_base<...>::before_invoke_hook()" is not generated,
leading to the error. It works with g++.

The error occurs with the LLVM 10.0.0 prebuilt binary for Ubuntu x86_64 and
using the Boost library version 1.73.0, on Linux Mint 19.3. It happens with
both LD and LLD. The Boost libraries were compiled with clang as well, but I
think this is not really relevant as the missing function is a template and
should be generated when compiling the application.

The code is compiled with "clang++ test.cpp -fuse-ld=lld -lboost_system
-pthread -lssl -lcrypto".

This is the missing function:
<a href="https://github.com/boostorg/beast/blob/boost-1.73.0/include/boost/beast/core/async_base.hpp#L193">https://github.com/boostorg/beast/blob/boost-1.73.0/include/boost/beast/core/async_base.hpp#L193</a>

The attached code of course makes zero sense, but appears to be the minimal
amount that reproduces the problem. It is unnecessarily contrived and I have
since been pointed to a better (and working) solution, but there may still be a
bug in Clang/LLVM that could be worth fixing.

The full linker error is:

ld.lld: error: undefined symbol: boost::beast::stable_async_base<void
LoaderConnection::onResolve<int>(int&&, boost::system::error_code const&,
boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp>
const&)::'lambda'(boost::system::error_code const&, unsigned long),
boost::asio::executor, std::allocator<void> >::before_invoke_hook()
<span class="quote">>>> referenced by test.cpp
>>>               /tmp/test-223f2a.o:(vtable for boost::beast::http::detail::write_msg_op<void LoaderConnection::onResolve<int>(int&&, boost::system::error_code const&, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&)::'lambda'(boost::system::error_code const&, unsigned long), boost::beast::ssl_stream<boost::beast::basic_stream<boost::asio::ip::tcp, boost::asio::executor, boost::beast::unlimited_rate_policy> >, true, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::allocator<char> > >)
>>> referenced by test.cpp
>>>               /tmp/test-223f2a.o:(vtable for boost::beast::stable_async_base<void LoaderConnection::onResolve<int>(int&&, boost::system::error_code const&, boost::asio::ip::basic_resolver_results<boost::asio::ip::tcp> const&)::'lambda'(boost::system::error_code const&, unsigned long), boost::asio::executor, std::allocator<void> >)</span >

ld.lld: error: undefined symbol:
boost::beast::detail::allocate_stable_state<boost::beast::http::serializer<true,
boost::beast::http::empty_body,
boost::beast::http::basic_fields<std::allocator<char> > >, std::allocator<void>
<span class="quote">>::~allocate_stable_state()
>>> referenced by test.cpp
>>>               /tmp/test-223f2a.o:(vtable for boost::beast::detail::allocate_stable_state<boost::beast::http::serializer<true, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::allocator<char> > >, std::allocator<void> >)</span >

ld.lld: error: undefined symbol:
boost::beast::detail::allocate_stable_state<boost::beast::http::serializer<true,
boost::beast::http::empty_body,
boost::beast::http::basic_fields<std::allocator<char> > >, std::allocator<void>
<span class="quote">>::~allocate_stable_state()
>>> referenced by test.cpp
>>>               /tmp/test-223f2a.o:(vtable for boost::beast::detail::allocate_stable_state<boost::beast::http::serializer<true, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::allocator<char> > >, std::allocator<void> >)</span >

ld.lld: error: undefined symbol:
boost::beast::detail::allocate_stable_state<boost::beast::http::serializer<true,
boost::beast::http::empty_body,
boost::beast::http::basic_fields<std::allocator<char> > >, std::allocator<void>
<span class="quote">>::destroy()
>>> referenced by test.cpp
>>>               /tmp/test-223f2a.o:(vtable for boost::beast::detail::allocate_stable_state<boost::beast::http::serializer<true, boost::beast::http::empty_body, boost::beast::http::basic_fields<std::allocator<char> > >, std::allocator<void> >)</span >
clang-10: error: linker command failed with exit code 1 (use -v to see
invocation)</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>