<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 - LIBCXX_ABI_OPTIMIZED_FUNCTION: Incomplete return type in template argument for std::function fails to compile"
   href="https://bugs.llvm.org/show_bug.cgi?id=46678">46678</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LIBCXX_ABI_OPTIMIZED_FUNCTION: Incomplete return type in template argument for std::function fails to compile
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>10.0
          </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>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>dschuff@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When using the optimized std::function ABI (LIBCXX_ABI_OPTIMIZED_FUNCTION)
and compiling the following:

#include <iostream>
#include <functional>
struct foo;
using fnc = std::function<foo(int)>;
struct bar {
    bar() {
        std::cout << "construct me" << std::endl;
    }
    fnc _f{nullptr};
};
int main(int argc, const char * argv[]) {
    // insert code here...
    std::cout << "Hello, World!\n";
    bar b{};
    return 0;
}

you get an error:
In file included from test.cc:1:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/iostream:37:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/ios:215:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/__locale:14:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/string:504:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/string_view:175:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/__string:56:
In file included from
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/algorithm:644:
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/functional:2051:16:
error: incomplete result type 'foo' in function definition
    static _Rp __call_empty(const __policy_storage*,
               ^
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/functional:2038:35:
note: in instantiation of member function
'std::__2::__function::__policy_invoker<foo (int)>::__call_empty' requested
here
    __policy_invoker() : __call_(&__call_empty) {}
                                  ^
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/functional:2090:5:
note: in instantiation of member function
'std::__2::__function::__policy_invoker<foo (int)>::__policy_invoker' requested
here
    __policy_func() : __policy_(__policy::__create_empty()) {}
    ^
/Users/dschuff/code/emr/emscripten-releases/emscripten/system/include/libcxx/functional:2276:5:
note: in instantiation of member function
'std::__2::__function::__policy_func<foo (int)>::__policy_func' requested here
    function(nullptr_t) _NOEXCEPT {}
    ^
test.cc:9:11: note: in instantiation of member function 'std::__2::function<foo
(int)>::function' requested here
    fnc _f{nullptr};
          ^
test.cc:3:8: note: forward declaration of 'foo'
struct foo;
       ^
1 error generated.


(this example uses emscripten, which currently uses libc++ 10.0 with some ABIv2
enabled)

If you instead use a complete type:
using fnc = std::function<void (int, foo&)>;
then it will compile.

On other platforms (and in libc++ using the stable std::function ABI) it also
works.</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>