You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
main: () = {
v: std::vector = ( 1, 2, 3, 4, 5 );
// Definite last use of v => move-capture v into f's closure
f := :() -> forward _ = { return v$; };
// Now we can access the vector captured inside f()...
f().push_back(6);
for f() do(e) std::cout << e; // prints 123456
}
Title: Capture considered local variable.
Description:
This is the example in the commit message of commit 4bd0c04.
But with a compound block instead.
Minimal reproducer (https://cpp2.godbolt.org/z/YTjP69cxP):
Commands:
cppfront main.cpp2 clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp
Expected result: Same as with
f := :() -> forward _ = v$;
.Actual result and error:
main.cpp2(5,31): error: a 'forward' return type cannot return a local variable
.See also:
forward
of capture$
crashes compiler #446.The text was updated successfully, but these errors were encountered: