Topic: aggregate storage in memory


Author: jefolts@oasis.novia.net (Jeff Folts)
Date: 1997/03/07
Raw View
Somewhere, I got the idea that aggregate storage of only
char types was defined in the language as not subject to
any special alignment/padding by the implementation.
Am I wrong?  Is it possible to run into a compiler that
will align the individual members?  Could the compiler
pad the end of the structure and "mess up" sizeof(charsonly)?
Are there other related issues?

Thanks for straightening me out.    B-)

class  charsonly
{
public:
   char a[10];
   char b[3];
   char c[7];
   char c[5];
} chunk_o_chars;
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1997/03/07
Raw View
jefolts@oasis.novia.net (Jeff Folts) writes:

>Somewhere, I got the idea that aggregate storage of only
>char types was defined in the language as not subject to
>any special alignment/padding by the implementation.
>Am I wrong?  Is it possible to run into a compiler that
>will align the individual members?  Could the compiler
>pad the end of the structure and "mess up" sizeof(charsonly)?

I believe the answer to all three questions is "yes".

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ 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         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]