[PATCH] D136554: Implement CWG2631

Jordan Rupprecht via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 29 20:22:22 PST 2022


rupprecht added a comment.

I threw this at the "test everything" test (some millions of targets) and it found only one breakage, so this is very very close. Without further ado, here is this silly looking thing:

File `blah.h`:

  #include <functional>
  #include <memory>
  
  template <typename T>
  struct Base {
    virtual ~Base() = default;
  };
  
  class Impl : public Base<int> {};
  
  struct ImplHolder {
    std::unique_ptr<Base<int>> impl = std::make_unique<Impl>();
  };
  
  struct GetImplCreators {
    std::function<ImplHolder()> impl_creator = []() { return ImplHolder{}; };
  };
  
  void UseImpl(GetImplCreators impl_creators = GetImplCreators{});

And `blah.cc`:

  #include "blah.h"
  
  void UseImpl(GetImplCreators impl_creators) {}

And lastly, `blah_main.cc`:

  #include "blah.h"
  
  void Func1() { UseImpl(); }
  // Note: it also fails when we explicitly specify the default arg, in case that is interesting.
  // void Func2() { UseImpl(GetImplCreators()); }
  
  int main(int argc, char* argv[]) { return 0; }

And here's the LLD output:

  ld: error: undefined hidden symbol: std::__u::__unique_if<Impl>::__unique_single std::__u::make_unique<Impl>()
  >>> referenced by blah_main.cc
  >>>               blah_main.o:(ImplHolder std::__u::__function::__policy_invoker<ImplHolder ()>::__call_impl<std::__u::__function::__default_alloc_func<GetImplCreators::impl_creator::'lambda'(), ImplHolder ()>>(std::__u::__function::__policy_storage const*))
  
  ld: error: undefined hidden symbol: std::__u::unique_ptr<Impl, std::__u::default_delete<Impl>>::~unique_ptr()
  >>> referenced by blah_main.cc
  >>>               blah_main.o:(ImplHolder std::__u::__function::__policy_invoker<ImplHolder ()>::__call_impl<std::__u::__function::__default_alloc_func<GetImplCreators::impl_creator::'lambda'(), ImplHolder ()>>(std::__u::__function::__policy_storage const*))

I'm out of time today so I don't have a repro script to offer, but I can dig into that when I get back next year if the source-only example is insufficient.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136554/new/

https://reviews.llvm.org/D136554



More information about the cfe-commits mailing list