Bug gcc 2.95.
Thomas Geocaris
tomATintimesw.com
Thu Sep 16 16:39:00 GMT 1999
I found the following behavior from gcc 2.95 on Solaris 2.7. When
inheriting an empty base
class with a static function, an extra word is added to the inherited
class. In the example below I expect the object size of class B to to
equal the size of class A (1 word). However, the compiler generates
sizeof(B) = 8 and sizeof(A) = 4.
Tom Geocaris
----------------------------------------------------------------
#include <stdio.h>
class base
{
public:
static void *operator new( size_t t )
{
void *p = 0;
return p;
}
};
class A
{
public:
int a;
};
class B : public base
{
public:
int b;
};
main()
{
printf("%d\n", sizeof(base) );
printf("%d\n", sizeof(A) );
printf("%d\n", sizeof(B) );
}
More information about the Gcc-bugs
mailing list