quakeforge/tools/qfcc/test/alignment.r
Bill Currie 4caa875442 Finish up alignment tests and add address cast
It turns out that initializing a local int with a pointer cast doesn't
work.
2020-02-15 23:49:12 +09:00

36 lines
683 B
R

int a;
double b;
int c;
double d;
void printf (string fmt, ...) = #0;
int main()
{
int fail = 0;
void *ap = &a;
void *bp = &b;
void *cp = &c;
void *dp = &d;
int aa = (int) ap;
int ba = (int) bp;
int ca = (int) cp;
int da = (int) dp;
if (ba & 1) {
printf ("double b is not aligned: %d\n", ba);
fail |= 1;
}
if (da & 1) {
printf ("double d is not aligned: %d\n", da);
fail |= 1;
}
if (ca - aa != 1) {
printf ("int c (%d) is not adjacant to int a (%d)\n", ca, aa);
fail |= 1;
}
if (ba <= ca) {
printf ("double b does not come after int c: %d %d\n", ba, ca);
fail |= 1;
}
return fail;
}