Skip to main content

ALIGNED_FIELDS_IN_PACKED

Static ALIGNED_FIELDS_IN_PACKED 

Source
pub static ALIGNED_FIELDS_IN_PACKED: &Lint
Expand description

The aligned_fields_in_packed lint detects fields with align representation hints inside repr(C) types with packed representation hint.

§Example

#[repr(C, align(16))]
struct Aligned(i32);

#[repr(C, packed)] // error!
struct Packed(Aligned);

{{produces}}

§Explanation

The behavior of this combination of hints is inconsistent across C compilers. The layout computed for these types by Rust may thus not match the layout actually used by C. Specifically, Rust always follows the GCC convention, which makes it incompatible with MSVC for these types. This may change in the future for targets where GCC is not the default C compiler.