Commit b7fd6635 by Stephane Carrez Committed by Jeff Law

* gcc.c-torture/execute/991014-1.c: New test.

From-SVN: r29970
parent 9180cca3
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> Wed Oct 13 22:01:35 1999 J"orn Rennecke <amylaar@cygnus.co.uk>
* g++.old-deja/g++.other/union2.C: New test. * g++.old-deja/g++.other/union2.C: New test.
......
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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment