OSDN Git Service

In gcc/:
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / consistency.vlad / layout / s-char-s-long.c
diff --git a/gcc/testsuite/consistency.vlad/layout/s-char-s-long.c b/gcc/testsuite/consistency.vlad/layout/s-char-s-long.c
new file mode 100644 (file)
index 0000000..996167d
--- /dev/null
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+static struct sss{
+  char f;
+  struct {long m;} snd;
+} sss;
+
+#define _offsetof(st,f) ((char *)&((st *) 16)->f - (char *) 16)
+
+int main (void) {
+  printf ("+++Struct long inside struct starting with char:\n");
+  printf ("size=%d,align=%d\n", sizeof (sss), __alignof__ (sss));
+  printf ("offset-char=%d,offset-sss-long=%d,\nalign-char=%d,align-sss-long=%d\n",
+          _offsetof (struct sss, f), _offsetof (struct sss, snd),
+          __alignof__ (sss.f), __alignof__ (sss.snd));
+  return 0;
+}