Skip to content

[BUG] calling a method on a class may do std::move on instance. #900

@tomFlowee

Description

@tomFlowee

Take this example code:

A: type = {
    connect: (inout this, s: std::string) = {
        std::cout << s;
    }
    foo: (inout this) = {}
}

main: (args) -> int = {
    a: A = ();
    a.connect("bla");
    // a.foo();
}

On gcc 13.2.1 this does not compile.
If you uncomment the 'a.foo()', the error changes.

Looks like the generated code: CPP2_UFCS(connect)(std::move(a), "bla"); adds a std::move there that should not be there when calling a method on that same object.
The error changes at uncomment because the 'std::move' is only generated for the last usage of the variable.

The final error is: note: no operand of the disjunction is satisfied

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions