if ((!lookup_attribute ("no_unique_address", DECL_ATTRIBUTES (memb1)))
!= !lookup_attribute ("no_unique_address", DECL_ATTRIBUTES (memb2)))
return false;
+ if (DECL_ALIGN (memb1) != DECL_ALIGN (memb2))
+ return false;
if (!tree_int_cst_equal (bit_position (memb1), bit_position (memb2)))
return false;
return true;
type2 = cp_build_qualified_type (type2, TYPE_UNQUALIFIED);
if (TREE_CODE (type1) == ENUMERAL_TYPE)
- return (TYPE_ALIGN (type1) == TYPE_ALIGN (type2)
- && tree_int_cst_equal (TYPE_SIZE (type1), TYPE_SIZE (type2))
+ return (tree_int_cst_equal (TYPE_SIZE (type1), TYPE_SIZE (type2))
&& same_type_p (finish_underlying_type (type1),
finish_underlying_type (type2)));
if (CLASS_TYPE_P (type1)
&& std_layout_type_p (type1)
&& std_layout_type_p (type2)
- && TYPE_ALIGN (type1) == TYPE_ALIGN (type2)
&& tree_int_cst_equal (TYPE_SIZE (type1), TYPE_SIZE (type2)))
{
tree field1 = TYPE_FIELDS (type1);
--- /dev/null
+// DR 2583 - Common initial sequence should consider over-alignment.
+// { dg-do compile { target c++11 } }
+
+#include <type_traits>
+
+struct A {
+ int i;
+ char c;
+};
+
+struct B {
+ int i;
+ alignas(8) char c;
+};
+
+struct C {
+ int i;
+ alignas(alignof(char)) char c;
+};
+
+struct D {
+ alignas(alignof(int)) int i;
+ char c;
+};
+
+struct S0 {
+ alignas(16) char x[128];
+ int i;
+};
+
+struct alignas(16) S1 {
+ char x[128];
+ int i;
+};
+
+#if __cpp_lib_is_layout_compatible >= 201907L
+static_assert (std::is_corresponding_member (&A::i, &B::i), "");
+static_assert (std::is_corresponding_member (&A::c, &B::c) == (alignof (char) == 8), "");
+static_assert (std::is_corresponding_member (&A::i, &C::i), "");
+static_assert (std::is_corresponding_member (&A::c, &C::c), "");
+static_assert (std::is_corresponding_member (&A::i, &D::i), "");
+static_assert (std::is_corresponding_member (&A::c, &D::c), "");
+static_assert (std::is_corresponding_member (&S0::x, &S1::x) == (alignof (char) == 16), "");
+static_assert (std::is_corresponding_member (&S0::i, &S1::i) == (alignof (char) == 16), "");
+#endif
static_assert (!std::is_layout_compatible_v<M, N>);
static_assert (!std::is_layout_compatible_v<O, P>);
static_assert (!std::is_layout_compatible_v<P, D>);
-static_assert (!std::is_layout_compatible_v<Q, R>);
+static_assert (std::is_layout_compatible_v<Q, R>);
static_assert (!std::is_layout_compatible_v<U, V>);
static_assert (!std::is_layout_compatible_v<A, I>);
static_assert (!std::is_layout_compatible_v<C, I>);
-static_assert (std::is_layout_compatible_v<E, F>);
+static_assert (!std::is_layout_compatible_v<E, F>);
static_assert (std::is_layout_compatible_v<G, H>);
static_assert (std::is_layout_compatible_v<C1, D1>);