llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Diagnose when an explicit alignment is weakened by other features

Open AaronBallman opened this issue 6 months ago • 2 comments

This was split off from a comment in #58638:

We might want to open another somewhat similar issue to diagnose when alignas is weakened by something else:

#pragma pack(2)
struct D2 {
  char m1;
  alignas(8) int m4;
};

static_assert(alignof(D2) == 2); // Clang and GCC accept, MSVC and EDG reject

AaronBallman avatar May 08 '26 16:05 AaronBallman

@llvm/issue-subscribers-clang-frontend

Author: Aaron Ballman (AaronBallman)

This was split off from a comment in #58638:

> We might want to open another somewhat similar issue to diagnose when alignas is weakened by something else: > cpp > #pragma pack(2) > struct D2 { > char m1; > alignas(8) int m4; > }; > > static_assert(alignof(D2) == 2); // Clang and GCC accept, MSVC and EDG reject >

@AaronBallman I've given this an attempt, please let me know if you have any feedback. Thank you

davidmenggx avatar May 18 '26 23:05 davidmenggx