Skip to content

C++ methods with rvalue this declared in a base class cannot be called from Swift #69745

Open
@egorzhdan

Description

@egorzhdan
struct Base {
  inline const char *rvalueThisInBase() const&&
      __attribute__((swift_attr("import_unsafe"))) {
    return "Base::rvalueThisInBase";
  }
};

struct Derived : Base {};
Derived().rvalueThisInBase()

This results in a compiler error:

<unknown>:0: error: 'this' argument to member function 'rvalueThisInBase' is an lvalue, but function has rvalue ref-qualifier
functions.h:25:22: note: 'rvalueThisInBase' declared here
  inline const char *rvalueThisInBase() const&&
                     ^
<unknown>:0: error: failed to synthesize call to the base method 'rvalueThisInBase()' of type 'rvalueThisInBase()'
<unknown>:0: error: missing return in instance method expected to return 'UnsafePointer<CChar>?' (aka 'Optional<UnsafePointer<Int8>>')

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions