From b7fd6635f6df825d588b765bba2342d20e968ba0 Mon Sep 17 00:00:00 2001 From: Stephane Carrez Date: Thu, 14 Oct 1999 12:23:10 +0200 Subject: [PATCH] * gcc.c-torture/execute/991014-1.c: New test. From-SVN: r29970 --- gcc/testsuite/ChangeLog | 4 +++ gcc/testsuite/gcc.c-torture/execute/991014-1.c | 50 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/execute/991014-1.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e6db32a..b5a9bf2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +Thu Oct 14 04:22:47 1999 Stephane Carrez + + * gcc.c-torture/execute/991014-1.c: New test. + Wed Oct 13 22:01:35 1999 J"orn Rennecke * 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 index 0000000..7b1b5fa --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/991014-1.c @@ -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; +} + -- 2.7.4