autocxx icon indicating copy to clipboard operation
autocxx copied to clipboard

C++ methods with reference qualifiers result in non-compiling wrappers

Open bsilver8192 opened this issue 3 years ago • 1 comments

Expected Behavior

Either ignore them or generate usable wrappers. I don't see a problem with ref-qualified methods, but rvalue-ref-qualified ones should probably be ignored because there's no good Rust analog for them.

Actual Behavior

C++ wrappers don't compile.

Specifically, it fails because it drops the ref-qualifier in the pointer-to-member-function type:

cargo:warning=/tmp/.tmpZHzT1q/target/cxx/gen0.cxx: In function ‘void cxxbridge1$A$foo(A&)’:
cargo:warning=/tmp/.tmpZHzT1q/target/cxx/gen0.cxx:137:31: error: cannot convert ‘void (A::*)() &’ to ‘void (A::*)()’ in initialization
cargo:warning=   void (::A::*foo$)() = &::A::foo;

Even if they did, I think overeager std::move in the wrappers will call rvalue-ref-qualified methods on C++ objects which are not being destroyed soon.

Probably a low priority. I've never seen C++ code which actually uses these, I just thought about it while thinking about all the kinds of special member functions.

PR with an ignored failing test incoming.

bsilver8192 avatar Feb 25 '22 08:02 bsilver8192

Next steps here: try to spot these cases and ignore them. Adding good-first-bug label since that may be straightforward, depending on the information we're given here by bindgen.

adetaylor avatar Apr 02 '23 02:04 adetaylor