Closed
Description
In the current implementation of cppfront (b370ab8), the following code:
main: () = {
b : bool = true;
if b {
std::cout << b << std::endl;
}
}
Generates:
auto main() -> int{
bool b {true};
if (std::move(b)) {
std::cout << std::move(b) << std::endl;
}
}
The b
variable is moved in the if condition despite its use in the if statement.
Adding the use of b
after an if removes the move of b
in the if condition and if statement which is correct.