From -2059214687866953461
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,b054a21715049ddb
X-Google-Attributes: gidf78e5,public
From: jkanze@otelo.ibmmail.com
Subject: Re: Placement of objects in ROM and physical object layout
Date: 1998/03/07
Message-ID: <6dre74$gs2$1@nnrp1.dejanews.com>#1/1
X-Deja-AN: 331689333
Content-Transfer-Encoding: quoted-printable
References: <87lnuqjry7.fsf@lickey.shell4.ba.best.com> <6dm38g$fhc$1@nnrp1.dejanews.com> <34FFC8D2.72B391A8@physik.tu-muenchen.de>
X-Original-Date: Sat, 07 Mar 1998 06:23:55 -0600
Content-Type: text/plain; charset=iso-8859-1
X-Http-User-Agent: Mozilla/4.03 [de] (WinNT; I)
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Sat Mar 07 12:23:55 1998 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBEAgUANQFGmuEDnX0m9pzZAQEmUgF4k1sCU0LzA5bdminUeZ3chjaIwRMcq7h2 I+CXtVN01FjQEp13iyN5hTNx6Bo8pF8= =ASrn
MIME-Version: 1.0
X-MIME-Autoconverted: from 8bit to quoted-printable by ncar.UCAR.EDU id FAA29233
Newsgroups: comp.std.c++


In article <34FFC8D2.72B391A8@physik.tu-muenchen.de>,
  Christopher Eltschka <celtschk@physik.tu-muenchen.de> wrote:
>
> jkanze@otelo.ibmmail.com wrote:

> > The standard only guarantees ordering for member variables declared
without
> > an intervening access specifier.
>
> Is this also true if the access specifier re-states the current state?
> That is, does
>
> class X
> {
> public:
>   char a;
>   int b;
>   char c;
> };
>
> guarantee the order of a, b, c and
>
> class Y
> {
>   public: char a;
>   public: int b;
>   public: char c;
> };
>
> not do so?

As I understand it, yes.

> If that's true, this would give an interesting optimizing guideline:
> If you are not interested in the exact order (and usually you
> aren't), then restate the access specifier for each member variable.
>
> (With alignment restrictions for int =3D=3D sizeof int =3D=3D 4, you wo=
uld
> have in the first case the layout (_ stands for padding bytes)
> a___bbbbc___ (giving sizeof X =3D=3D 12), while the second could be
> optimized by a good compiler to ac__bbbb (giving sizeof Y =3D=3D 8).
> If ints are only two-byte aligned, you'd even need no padding at all
> for Y!

Well, I've yet to see a compiler that actually rearranges the order
even when it is allowed.  So don't expect much optimization with this
with current compilers.

--
James Kanze    +33 (0)1 39 23 84 71    mailto: kanze@gabi-soft.fr
        +49 (0)69 66 45 33 10    mailto: jkanze@otelo.ibmmail.com
GABI Software, 22 rue Jacques-Lemercier, 78000 Versailles, France
Conseils en informatique orient=E9e objet --
              -- Beratung in objektorientierter Datenverarbeitung

-----=3D=3D Posted via Deja News, The Leader in Internet Discussion =3D=3D=
-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



