Skip to content

Replace confusing note in cpp.md on "RVO" #2327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions book/src/cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ cannot translate into Rust:
[the tracking issue for exceptions](https://github.com/rust-lang/rust-bindgen/issues/1208)
for more details.

* Return value optimization. C++ compilers will in certain circumstances optimize functions
returning a struct type value to instead take an extra hidden argument that refers
to the return value struct. `bindgen` cannot necessarily know about this optimization and
thus at present `bindgen`-interfaces for these kinds of functions are invalid.
* Many C++ specific aspects of calling conventions. For example in the Itanium abi types that are
"[non trivial for the purposes of calls](https://itanium-cxx-abi.github.io/cxx-abi/abi.html#non-trivial)"
should be passed by pointer, even if they are otherwise eligable to be passed in a register.
Similarly in both the Itanium and MSVC ABIs such types are returned by "hidden parameter", much like
large structs in C that would not fit into a register. This also applies to types with any base classes
in the MSVC ABI (see [x64 calling convention](https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#return-values)).
Because bindgen does not know about these rules generated interfaces using such types are currently invalid.