From: Tiago Stein <tiago@lisha.ufsc.br>
To: gcc@gcc.gnu.org
Subject: Double abstract class Inheritance concern.
Date: Mon, 29 Mar 2004 13:57:00 -0000 [thread overview]
Message-ID: <65184.200.138.253.131.1080515997.squirrel@www.lisha.ufsc.br> (raw)
Hy! I have question concerning inheritance of empty classes.
Supose that I have:
Class A{
};
Class B: public A{
unsigned int foo1;
};
because of C++ constraints on object sizes.. sizeof(A) is 4 (I am in a
32bit PC).
In class B, due to the attribute.. this extra size form A is supressed. So
sizeof B= 4 too..
Until here everything is OK, but... given:
class A{
};
class B :public A{
};
class C: public A{
int g;
};
class D: public B, public C
{
unsigned int foo;
};
Why sizeof class D is 12? Should not be 8? Why the extra size from the
empty classes is not eliminated this time? Is this due to any rules in the
standard? I passed hours looking for it but found nothing that could
obligate so. This behavior is causing some real nasty side-effects in our
operating system due to memory restrictions in our embedded targets.
So, can someone explain me why of this? Maybe I am leaving something wrong
pass at my design if there is any rule that dictates this behavior.
Thanks for any help.
next reply other threads:[~2004-03-28 23:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-29 13:57 Tiago Stein [this message]
2004-03-29 15:15 ` Alexandre Oliva
2004-03-29 14:03 Chris Lattner
2004-03-29 17:16 ` Nathan Sidwell
2004-03-29 18:49 ` Joe Buck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=65184.200.138.253.131.1080515997.squirrel@www.lisha.ufsc.br \
--to=tiago@lisha.ufsc.br \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).