Recent regression __alignof__ long double
Nathan Sidwell
nathan@acm.org
Fri Feb 11 15:18:00 GMT 2000
Hi,
here's a new failing testcase. On linux-i86 alignment of
long double is now 12, this is bogus, the alignment must be a power of
2. The alignment of a struct must be the LCM of the contained alignments.
So if one of the alignments is not a power of 2, the struct's alignment
can't be. In this test case, that doesn't happen.
I've not yet looked to figure out when this brok, but it's in the
last month.
ok?
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
Never hand someone a gun unless you are sure where they will point it
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
// Special g++ Options:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 12 Feb 2000 <nathan@acm.org>
// __alignof__ should never return a non-power of 2
// eg, sizeof(long double) might be 12, but that means it must be alignable on
// a 4 byte boundary
// execution test - XFAIL - i?86-*-linux*
#include <stdio.h>
static int fail = 0;
void check (char const *type, int align)
{
if ((align & -align) != align)
{
printf ("type `%s' has alignment of %d\n", type, align);
fail = 1;
}
}
#define QUOTE_(s) #s
#define QUOTE(s) QUOTE_(s)
#define check(t) check(QUOTE(t), __alignof__(t))
// This struct should have an alignment of the lcm of all the types. If one of
// the base alignments is not a power of two, then A cannot be power of two
// aligned.
struct A
{
bool b;
char c;
signed short ss;
unsigned short us;
signed int si;
unsigned int ui;
signed long sl;
unsigned long ul;
signed long long sll;
unsigned long long ull;
float f;
double d;
long double ld;
void *dp;
void (*fp)();
int A::*mdp;
int (A::*mfp)();
};
int main ()
{
check (void);
check (bool);
check (char);
check (signed short);
check (unsigned short);
check (signed int);
check (unsigned int);
check (signed long);
check (unsigned long);
check (signed long long);
check (unsigned long long);
check (float);
check (double);
check (long double);
check (void *);
check (void (*)());
check (int A::*);
check (int (A::*)());
check (A);
return fail;
}
More information about the Gcc-bugs
mailing list