rust-lang / rust-lang/rust-bindgen
Wrong constructor on MSVC (default constructor closure)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
To confirm, it looks like that extra constructor case is the "default
constructor closure," which is generated when dllexporting a default
constructor that requires some extra code to call, and the
clang_Cursor_getCXXManglingssolution handles it incorrectly.For example, this code generates two constructors, with symbols
??0Foo@@QEAA@H@Z(public: __cdecl Foo::Foo(int)) and??_FFoo@@QEAAXXZ
(public: void __cdecl Foo::\default constructor closure'(void)`).struct __declspec(dllexport) Foo { Foo(int x = 3); };Bindgen declares the first but gives it the link_name of the second:
extern "C" { #[link_name = "??_FFoo@@QEAAXXZ"] pub fn Foo_Foo(this: *mut Foo, x: ::std::os::raw::c_int); }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the reported MSVC case using the shown dllexported C++ Foo with a default argument, then inspect how clang_Cursor_getCXXManglings is used for constructor declarations. Compare the generated Foo_Foo declaration with the two symbols described in the issue; done means the declared constructor is linked to the actual constructor symbol rather than the default constructor closure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100