-
Notifications
You must be signed in to change notification settings - Fork 258
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] Trying to 'std::move' when using with std::cin a last use variable #609
Comments
The fix is to use it again by discarding it, e.g., |
Is this not actually highlighting an error in your code?
On 21 August 2023 22:08:57 Soraphis ***@***.***> wrote:
Describe the bug
If the guaranteed last use of a variable is in a std::cin a compiler error is thrown, since the cppfront generated code tries to std::move the variable.
First I did not realize it was because of the guaranteed last use, and while it is kinda nonsensical to read into a variable without ever reading from it, it was kinda confusing to get the cpp compiler error, as that meant I'd had to look into the cpp file as the cpp2 file was kinda "fine".
To Reproduce
https://cpp2.godbolt.org/z/d9e4bKGKW
—
Reply to this email directly, view it on GitHub<#609>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AALUZQJ52HXFXXCYAUB7Q7DXWPE6NANCNFSM6AAAAAA3Y6GNJA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
I'm usign VS Code for toying a bit around, so ... no, not really. Especially not in the cpp2 code. cppfront also runs through just fine. and as usual, c++ error messages being perfectly understandable for humans:
yeah, I kinda understand that now, but the error message I see will not always be same and it kinda confused me quite a bit. I mean ... it says here (https://github.com/hsutter/cppfront/wiki/Design-note:-Explicit-discard)
But I kinda fail to see where the feature is, as it didn't tell me anything, tbh.
then I'd know where the error is coming from (and how to resolve it). because if i don't get this hint, the errors which I get don't help me reaching the wiki page where it is explained. |
Unfortunately, Cppfront is a transpiler. |
Maybe the error message could be improved in cases where a cpp2 function with an |
Describe the bug
If the guaranteed last use of a variable is in a std::cin a compiler error is thrown, since the cppfront generated code tries to std::move the variable.
First I did not realize it was because of the guaranteed last use, and while it is kinda nonsensical to read into a variable without ever reading from it, it was kinda confusing to get the cpp compiler error, as that meant I'd had to look into the cpp file as the cpp2 file was kinda "fine".
To Reproduce
https://cpp2.godbolt.org/z/d9e4bKGKW
The text was updated successfully, but these errors were encountered: