Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: use _Alignof rather than offsetof() on most compilers #23031

Merged
merged 1 commit into from Jan 18, 2023

Commits on Jan 17, 2023

  1. BUG: use _Alignof rather than offsetof() on most compilers (numpy…

    …#23016)
    
    WG14 N2350 made very clear that it is an UB having type definitions
    within "offsetof" [1]. This patch enhances the implementation of macro
    _ALIGN to use builtin "_Alignof" to avoid undefined behavior on
    when using std=c11 or newer
    
    clang 16+ has started to flag this [2]
    
    Fixes build when using -std >= gnu11 and using clang16+
    
    Older compilers gcc < 4.9 or clang < 8 has buggy _Alignof even though it
    may support C11, exclude those compilers too
    
    [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm
    [2] https://reviews.llvm.org/D133574
    
    Signed-off-by: Khem Raj <raj.khem@gmail.com>
    
    * Apply suggestions from code review
    
    Signed-off-by: Khem Raj <raj.khem@gmail.com>
    Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
    2 people authored and charris committed Jan 17, 2023
    Configuration menu
    Copy the full SHA
    b3760fe View commit details
    Browse the repository at this point in the history