Static assert fails when compiler for i386

Hi Devs,
Consider below testcase.
$cat test.cpp

#include
#include<type_traits>
typedef int _int4 attribute((vector_size(16)));
typedef union{
int data[4];
struct {int x, y, z, w;};
_int4 vec;
} int4;
typedef int4 int3;
int main()
{
static_assert(std::alignment_of::value <= alignof(max_align_t), “over aligned!”);
}

$clang++ -m32
error: static_assert failed due to requirement ‘std::alignment_of::value <= alignof(max_align_t)’ "over aligned

it goes smooth when compile for x86_64.
Following changes fixes this.

diff --git a/clang/lib/Headers/__stddef_max_align_t.h b/clang/lib/Headers/__stddef_max_align_t.h
index e3b439285d0…46f705a09c3 100644
— a/clang/lib/Headers/__stddef_max_align_t.h
+++ b/clang/lib/Headers/__stddef_max_align_t.h
@@ -21,6 +21,10 @@ typedef struct {
attribute((aligned(alignof(long long))));
long double __clang_max_align_nonce2
attribute((aligned(alignof(long double))));

  • #ifdef i386
  • typedef double xx attribute((vector_size(16)));
  • xx __clang_max_align_nonce3 attribute((aligned(alignof(xx))));
  • #endif
    } max_align_t;
    #endif

Like to know community thought on this?

max_align_t is a type whose alignment requirement is as large as any scalar type, but your int4 is not a scalar type but a union containing a vector _int4, so it looks like your assertion is simply incorrect.

Thank you, Rui for clarification.