What is correct sizeof(Foo) ?
Four compilers:
aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]
CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
Intel(R) C++ Version 11.0.083
Microsoft C/C++ 14.00.50727
produce sizeof(Foo) == 1
IBM XL C/C++ Enterprise Edition V8.0 for AIX Version: 08.00.0000.0014
IBM XL C/C++ Enterprise Edition for AIX, V9.0 Version: 09.00.0000.0008
produce sizeof(Foo) == 4.
Alex Vinokur
At least 1.
> Four compilers:
> aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]
> CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
> Intel(R) C++ Version 11.0.083
> Microsoft C/C++ 14.00.50727
> produce sizeof(Foo) == 1
>
> IBM XL C/C++ Enterprise Edition V8.0 for AIX Version: 08.00.0000.0014
> IBM XL C/C++ Enterprise Edition for AIX, V9.0 Version: 09.00.0000.0008
> produce sizeof(Foo) == 4.
So?
Cheers,
- Alf
Anything greater than 0.
>
>Four compilers:
> aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]
> CC: Sun C++ 5.9 SunOS_sparc Patch 124863-01 2007/07/25
> Intel(R) C++ Version 11.0.083
> Microsoft C/C++ 14.00.50727
>produce sizeof(Foo) == 1
>
>IBM XL C/C++ Enterprise Edition V8.0 for AIX Version: 08.00.0000.0014
>IBM XL C/C++ Enterprise Edition for AIX, V9.0 Version: 09.00.0000.0008
>produce sizeof(Foo) == 4.
>
It's hardly surprising that alignment and padding requirements of
different architectures tend to differ.
--
Richard Herring
> What is correct sizeof(Foo) ?
Either implementation defined or unspecified, I'm not sure
which. (Implementation defined means that the implementation
must document what it does---in this case, how it lays out bit
fields, etc. Unspecified frees the implementation of the
documentation requirement.)
--
James Kanze (GABI Software) email:james...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
I believe documentation is required:
§9.6/1: "Allocation of bit-fields within a class object is
implementation-defined. Alignment of bit-fields is implementation-
defined."
--
Later,
Jerry.
> > > What is correct sizeof(Foo) ?
> > Either implementation defined or unspecified, I'm not sure
> > which. (Implementation defined means that the
> > implementation must document what it does---in this case,
> > how it lays out bit fields, etc. Unspecified frees the
> > implementation of the documentation requirement.)
> I believe documentation is required:
> §9.6/1: "Allocation of bit-fields within a class object is
> implementation-defined. Alignment of bit-fields is
> implementation- defined."
Then documentation is required. (Good luck on finding it,
however.)
Thanks for looking it up for me. (I could have looked it up as
well, but was just too lazy to.)