2010-01-20 Jason Merrill <jason@redhat.com>
+ PR c++/41788
+ * class.c (layout_class_type): Set packed_maybe_necessary for packed
+ non-PODs.
+
PR c++/41920
* semantics.c (build_lambda_object): Call mark_used on captured
variables.
build_decl (input_location,
FIELD_DECL, NULL_TREE, char_type_node));
+ /* If this is a non-POD, declaring it packed makes a difference to how it
+ can be used as a field; don't let finalize_record_size undo it. */
+ if (TYPE_PACKED (t) && !layout_pod_type_p (t))
+ rli->packed_maybe_necessary = true;
+
/* Let the back end lay out the type. */
finish_record_layout (rli, /*free_p=*/true);
2010-01-20 Jason Merrill <jason@redhat.com>
+ PR c++/41788
+ * g++.dg/abi/packed1.C: New.
+
PR c++/41920
* g++.dg/cpp0x/lambda/lambda-warn1.C: New.
--- /dev/null
+// PR c++/41788
+// { dg-options "-Wpacked" }
+// { dg-do run }
+
+extern "C" void abort ();
+
+struct INNER {
+ virtual int foo() const { return 1; }
+} __attribute__ ((packed));
+
+struct OUTER {
+ char c;
+ INNER inner;
+} __attribute__ ((packed));
+
+int main()
+{
+ OUTER outer;
+ int s = sizeof(outer);
+ int o = (char *)&outer.inner - (char *)&outer;
+ if (s != sizeof (char) + sizeof (void*)
+ || o != sizeof (char))
+ abort ();
+}