Bug ID: 37089
           Summary: clang does not generate a template instance in a very
                    specific case
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++14

I have a strange bug where clang seems to forget to generate a template

Here is the code, reduced as much as I could:

    template <class T>
    T declval()
      T* v = nullptr;
      return *v;
    template <class F, class... Args>
    auto do_call(F func, Args&&... args) -> decltype(func(args...))
      return func(args...);

    template <class F, class... Args>
    struct __func
      virtual void buggy_method()
        do_call(declval<F>(), Args{}...);

    template <typename C>
    void async_resumable(C cb)
      auto l = [cb](auto&&... args) { cb(args...); };
      __func<decltype(l), int> y;

    int main()
      async_resumable([&](auto) -> void { async_resumable([](int) {}); });

On clang 5, 6 and trunk, compiling this gives the following error:

    $ /usr/bin/clang++-5.0  -std=c++14 -o /dev/null ok.ii 
    /tmp/ok-5eaa37.o:(.rodata+0x80): undefined reference to
    clang: error: linker command failed with exit code 1 (use -v to see

- If you remove the "-> void" in the last lambda, the symbol is generated and
the code compiles
- If you replace the "auto" argument in the last lambda by "int", it also works
- GCC 7 compiles the code successfully in all cases.

If it's of any matter, in real life, that __func class is the one in
std::function in libc++.

You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to