[llvm-bugs] [Bug 40512] Binary size exploding when using a lambda in a template with multiple parameters

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 7 11:05:34 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40512

David Blaikie <dblaikie at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #6 from David Blaikie <dblaikie at gmail.com> ---
(In reply to A. Joël Lamotte from comment #5)
> Thank you very much for this clarification, it helps a lot.
> Not sure what to do about it. Probably that would need some change to the
> standard to be fixed, or an epic effort from compiler impls.

Yep, pretty much.

For the original code, you've got the external function which is probably the
simplest thing to do. (you could outline more of the code to reduce duplication
further - incnluding the thread construction and usage:

template<typename A>
void do_f(A a) {
  std::thread t{
    [a] {
      if (a % 2 == A(0)) {
        std::cout << "even: " << a << '\n';
      } else {
        std::cout << "odd: " << a << '\n';
      }
    }
  };
  t.detach();
}

...
  auto f() const {
    do_f(a);
  }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190207/54dbc1cf/attachment.html>


More information about the llvm-bugs mailing list