镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

In parameter move from last use #18

Description

@hsutter

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
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions