Bizaare non-constant class sizes.
Andrew Over
ajo@acm.org
Thu May 11 22:41:00 GMT 2000
On Fri, May 12, 2000 at 07:08:22AM +0200, Martin v. Loewis wrote:
> GCC 2.95 would (incorrectly) allow that fields of a class are
> variable-length arrays. That might cause the problem you see.
I'm not even using fixed-length arrays inside the class, so that's not
the cause.
> Please note that egcs-bugs is an address to report bugs, not one to
> ask questions about the compiler.
Maybe I didn't properly explain what's going on.
Consider the following (in a header file):
class a {
int a;
};
class b {
int b;
};
class c : public a, public b {
int c;
};
Now, if I print sizeof(class c) in one file, I get 12. If I do it in
a different file, I get 8 (clearly too small). foo = new c() in this
file results in a segfault. Obviously the value should be constant
across every file that includes this definition.
I had a look through gnats for something similar, but without luck,
and was wondering if this bug had been reported before (or if there
was a workaround).
I'll try to obtain the .ii stuff tomorrow if I can't figure out a way
around this.
Thanks,
--Andrew
More information about the Gcc-bugs
mailing list