Consider this code snippet:
int main () {
auto first = [&] (auto... one) {
auto faulty = [&] () {
[[maybe_unused]] auto i = (one + ...);
return (one + ...);
};
faulty();
};
first(1);
}
See also on godbolt .
It seems that when I try to expand the implicitly captured parameter pack one
twice inside the inner lambda, gcc complains, but clang does not. Note that when I explicitly capture, like so [&one...]
, gcc doesn't complain anymore.
To me this looks like a gcc bug, but I would like some confirmation from people who are more experienced than me, since I have already seen (different) buggy behaviour in clang with variadic captures here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.