Skip to content

OS_SockAddr_t alignment issue on some architectures #295

@jphickey

Description

@jphickey

Describe the bug
On some CPU architectures that have strict alignment requirements, the OS socket address storage buffer triggers a warning/error about casts that increase alignment. For example:

os-impl-bsd-sockets.c:200:9: error: cast increases required alignment of target type [-Werror=cast-align]
    sa = (const struct sockaddr *)Addr->AddrData;

To Reproduce
Build on an architecture that has strict alignment requirements (e.g. SPARC, MIPS, etc)

Expected behavior
Should build cleanly, no warnings.

System observed on:

  • MIPS Linux (QEMU)

Additional context
Not likely to be a "real" alignment issue as this specific instance follows a uint32 value, so it will already have 32 bit alignment already. Adding a union wrapper will squelch the warning though.

Reporter Info
Joseph Hickey, Vantage Systems, Inc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions