rust-lang / rust-lang/rust-bindgen
internal error: sizeof(string_view) != 32
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
Input C/C++ Header
#pragma once
#include <string>
void f(std::string_view);
Bindgen Invocation
$ bindgen test.h -- -x c++ -std=c++17
Actual Results
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct std_basic_string_view<_CharT> {
pub _M_len: std_size_t,
pub _M_str: *const _CharT,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_CharT>>,
}
...
#[test]
fn __bindgen_test_layout_std_basic_string_open0_char_std_char_traits_open1_char_close1_std_allocator_open1_char_close1_close0_instantiation(
) {
assert_eq!(
::std::mem::size_of::<std_basic_string<::std::os::raw::c_char>>(),
32usize,
concat!(
"Size of template specialization: ",
stringify!(std_basic_string<::std::os::raw::c_char>)
)
);
assert_eq!(
::std::mem::align_of::<std_basic_string<::std::os::raw::c_char>>(),
8usize,
concat!(
"Alignment of template specialization: ",
stringify!(std_basic_string<::std::os::raw::c_char>)
)
);
}
Expected Results
As you can see "unit" tests expect that size of struct with c_char will be 32,
this tests failed on Linux/amd64, because of size of equals 16.
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 issue with test.h and the shown bindgen command using C++17. Inspect the generated std_basic_string_view layout and its emitted size and alignment test; done means this input no longer produces an incorrect failing layout assertion on Linux/amd64.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100