Skip to content

#[repr(align(4))] struct has 8 byte alignmentΒ #48159

Open
@gnzlbg

Description

@gnzlbg

See it live:

#![allow(non_camel_case_types)]
pub enum c_void {}

type uintptr_t = usize;
type int16_t = u16;
type uint16_t = int16_t;
type uint32_t = u32;
type intptr_t = uintptr_t;

#[repr(C)]
#[repr(align(4))]
pub struct kevent {
    pub ident: uintptr_t,
    pub filter: int16_t,
    pub flags: uint16_t,
    pub fflags: uint32_t,
    pub data: intptr_t,
    pub udata: *mut c_void,
}

fn main() {
    assert_eq!(::std::mem::align_of::<kevent>(), 4); // ERROR: 8 != 4
}

No warning, no error, nu nothing.

This is rust-lang/libc#914

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-alignArea: alignment control (`repr(align(N))` and so on)A-diagnosticsArea: Messages for errors, warnings, and lintsA-reprArea: the `#[repr(stuff)]` attributeC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions