708 icon indicating copy to clipboard operation
708 copied to clipboard

In parameter move from last use

Open hsutter opened this issue 5 years ago • 0 comments

The last line prints 1, but it should print 2 because f(param) is the definite last use of the param... Godbolt repro: https://cppx.godbolt.org/z/17noYP

struct X {}; 
void f(X const&) { cout << "1\n"; } 
void f(X &&    ) { cout << "2\n"; } 

void test(in X param) { f(param); }

int main() { 
    X x; 
    test(x);       // 1 

    test(X());     // *** should be 2
}

hsutter avatar Dec 28 '20 19:12 hsutter