SET_DECL_ALIGN (sinit, sd->alignment.get () * BITS_PER_UNIT);
DECL_USER_ALIGN (sinit) = true;
}
+ else if (sd == NULL)
+ {
+ /* Alignment of class is determined its biggest field alignment. */
+ SET_DECL_ALIGN (sinit, decl->alignsize * BITS_PER_UNIT);
+ DECL_USER_ALIGN (sinit) = true;
+ }
decl->sinit = sinit;
return sinit;
storage class, then the instance is allocated on the stack
rather than the heap or using the class specific allocator. */
tree var = build_local_temp (TREE_TYPE (type));
+ SET_DECL_ALIGN (var, cd->alignsize * BITS_PER_UNIT);
+ DECL_USER_ALIGN (var) = 1;
new_call = build_nop (type, build_address (var));
setup_exp = modify_expr (var, aggregate_initializer_decl (cd));
}
build_type_decl (basetype, t->sym);
set_visibility_for_decl (basetype, t->sym);
apply_user_attributes (t->sym, basetype);
- finish_aggregate_type (t->sym->structsize, t->sym->alignsize, basetype);
+ /* The underlying record type of classes are packed. */
+ finish_aggregate_type (t->sym->structsize, 1, basetype);
/* Classes only live in memory, so always set the TREE_ADDRESSABLE bit. */
for (tree tv = basetype; tv != NULL_TREE; tv = TYPE_NEXT_VARIANT (tv))
--- /dev/null
+// { dg-do compile }
+// { dg-additional-options "-Warray-bounds" }
+extern(C++) class C117002
+{
+ ubyte[4] not_multiple_of_8;
+}
+
+int pr117002a(void *p)
+{
+ auto init = __traits(initSymbol, C117002);
+ if (init.ptr + init.length <= p)
+ return 1;
+ return 0;
+}
+
+void pr117002b(void *p)
+{
+ auto init = __traits(initSymbol, C117002);
+ p[0 .. init.length] = init[];
+}
+
+void pr117002c()
+{
+ scope var = new C117002;
+ void *p = cast(void*)var;
+ auto init = __traits(initSymbol, C117002);
+ p[0 .. __traits(classInstanceSize, C117002)] = init[];
+}