I am trying to capture a variadic lambda argument inside a inner lambda and use it there. As an example, consider this code:
int main () {
auto first = [&] (auto&&... one) {
auto second = [&] (auto&&... two) {
return ((one * two) + ...);
};
return second(one...);
};
return first(5);
}
This works with gcc9 but fails with clang8 (https://godbolt.org/z/i2K9cK).
A way to make the code compile is to explicitly capture [&one...]
, but i was wondering whether this is a bug in clang.
Also interesting: Changing the return statement to something where one
is directly expanded (before combining with two
), this compiles again:
return (((one * ...) * two) + ...);
I have found this related post, but the bug declared there seems to be fixed in clang8.