Article View: comp.std.c++
Article #3848Re: Quick questions
From: Wil Evers
Date: Thu, 28 Mar 1996 15:56
Date: Thu, 28 Mar 1996 15:56
35 lines
2136 bytes
2136 bytes
In article <4jajk2$17aq@mule1.mindspring.com> abell@mindspring.com (Andrew
Bell) writes:
> clamage@Eng.sun.com (Steve Clamage) wrote:
> [snip]
>
> >I assume you mean a class like
> > class Short { short val; };
> >with non-virtual member functions added. You can't assume the size and
> >alignment of the class will be the same as its only data member, and
> >no, the standard provides no special support for this special case.
>
> Seems like if you only have one data member and no virtual functions,
> there's no reason to arbitrarily restrict it to a greater alignment
> level, save maybe to make compiler programmer's lives (and maybe
> debugger programmer's lives) trivially easier.
I few weeks ago, I ran into a similar problem (I was wrapping a struct around a
plain character array, which unexpectely changed its alignment), and I did some
enquires on comp.std.c.
It turns out some platforms have different optimal pointer representations
depending on the alignment of what's being pointed to. Since you don't need to
define a structure before you declare a pointer to it, assuming all structures
are maximally aligned "just because they're structures" may actually result in
more efficient code on these machines.
- Wil
[ 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 ]
Technical Details
Message-ID:
<009A0046789FF2A0.3D60EEDA@ittpub.nl>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: "Wil Evers" <wil@ittpub.nl> Newsgroups: comp.std.c++ Subject: Re: Quick questions Date: 28 Mar 1996 15:56:16 GMT Organization: Sun Microsystems Inc., Mountain View, CA Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <009A0046789FF2A0.3D60EEDA@ittpub.nl> NNTP-Posting-Host: taumet.eng.sun.com X-Vms-Mail-To: IN%"std-c++@ncar.ucar.edu" Content-Length: 1238 X-Lines: 28 Originator: clamage@taumet