-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Move on definitive last use in fold expressions #1279
Comments
You discard it with |
Awesome, thank you! For some reason I convinced myself that I couldn't use that in an expression and just as a standalone statement and didn't even try to use it... Glad to see it was just a user error on my part :) |
Looks like there's an opportunity for improving the diagnostic here. |
Yeah, that would have definitely helped me and I'd guess anyone else starting out with |
…'as void' For replacing 'unsafe_*': Thanks to Redditor @tialaramex for their suggestion here, presuasively citing Rust's naming style (and thanks to the Rust designers too for the inspiration): https://www.reddit.com/r/cpp/comments/1euacbu/cpp2_is_looking_absolutely_great_will_convert/liy6g8r/ For replacing 'as void': Thanks to @Velocirobtor and @JohelEGP for their suggestions on improving this diagnostic in the #1279 comment thread.
Thanks! This part is done: 07b0eed |
Describe the bug
If the definitive last use of a variable is inside a fold expression, cppfront will still emit
cpp2::move(<variable>)
even though this will most likely lead to multiple moves from<variable>
.To Reproduce
Compile the following cpp2 code:
This will generate this cpp1 code (omitting forward declarations):
which prints " true true"
Expected Behavior
I think one of the following should happen:
The first would just require not emitting
cpp2::move
in fold expressions. The latter could be achieved by generating code somewhere along the lines of:Link to Godbolt with the complete example: https://cpp2.godbolt.org/z/fcjWPfhsh
P.S. How can I silence the warning
left operand of comma operator has no effect
usingcpp2
Syntax? I triedstatic_cast<void>(Is)
which lead to cppfront suggestingIs as void
, which didn't work.The text was updated successfully, but these errors were encountered: