Thread View: comp.std.c++
1 messages
1 total messages
Started by Wil Evers
Thu, 28 Mar 1996 15:56
Re: Quick questions
Author: 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 ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads