* gcc.c-torture/execute/991014-1.c: New test.
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Oct 1999 10:23:10 +0000 (10:23 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 14 Oct 1999 10:23:10 +0000 (10:23 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@29970 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/991014-1.c [new file with mode: 0644]

index e6db32a..b5a9bf2 100644 (file)
@@ -1,3 +1,7 @@
+Thu Oct 14 04:22:47 1999  Stephane Carrez  <stcarrez@worldnet.fr>
+
+       * gcc.c-torture/execute/991014-1.c: New test.
+
 Wed Oct 13 22:01:35 1999  J"orn Rennecke <amylaar@cygnus.co.uk>
 
        * g++.old-deja/g++.other/union2.C: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/991014-1.c b/gcc/testsuite/gcc.c-torture/execute/991014-1.c
new file mode 100644 (file)
index 0000000..7b1b5fa
--- /dev/null
@@ -0,0 +1,50 @@
+
+typedef typeof(sizeof(char)) Size_t;
+
+#define bufsize ((1L << (8 * sizeof(Size_t) - 2))-256)
+
+struct huge_struct
+{
+  short buf[bufsize];
+  int a;
+  int b;
+  int c;
+  int d;
+};
+
+union huge_union
+{
+  int a;
+  char buf[bufsize];
+};
+
+unsigned long union_size()
+{
+  return sizeof(union huge_union);
+}
+
+unsigned long struct_size()
+{
+  return sizeof(struct huge_struct);
+}
+
+unsigned long struct_a_offset()
+{
+  return (unsigned long)(&((struct huge_struct *) 0)->a);
+}
+
+int main()
+{
+  /* Check the exact sizeof value. bufsize is aligned on 256b. */
+  if (union_size() != sizeof(char) * bufsize)
+    abort();
+
+  if (struct_size() != sizeof(short) * bufsize + 4*sizeof(int))
+    abort();
+
+  if (struct_a_offset() < sizeof(short) * bufsize)
+    abort();  
+
+  return 0;
+}
+