incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek" <Travis.Vi...@roguewave.com>
Subject RE: svn commit: r669735 - in /stdcxx/branches/4.3.x: include/rw/_meta_other.h include/type_traits tests/utilities/20.meta.trans.other.cpp
Date Thu, 26 Jun 2008 23:05:55 GMT
 

Martin Sebor wrote:
>
>Travis Vitek wrote:
>> 
>> I'm not absolutely sure I'm reading the documentation you linked to
>> correctly, but here goes...
>
>It's possible that I misread the text. I was pretty sure (and still
>am) I remembered discussing the alignment issue before but I couldn't
>(and still can't) find it in the archives. I pointed to this page
>because that was the best I could come up with in the absence of
>anything else. Maybe it's a red herring. It could also be that the
>issue I think I'm remembering had less to do with alignment than
>something else (aliasing, maybe), but given the choice between
>placing the more strictly aligned type first and the unaligned
>buffer second or doing laying them down in the reverse order I'd
>go for the former even if there is no real issue.
>
>I searched library headers and sources for how we define unions and
>with the exception of limits_bits.cpp we always follow this rule.
>Unless there is a reason not to make this change to aligned_union,
>I think we should change both limits_bits.cpp and aligned_union to
>always define the member with the more strict alignment requirement
>first, just for peace of mind.

Good thing you didn't look at my original implementation of
aligned_union. :)

>
>Is there any reason/advantage to having the char buffer first?
>

Not that I know of. I'll update them all.

>> 
>> The first paragraph of that documentation says
>> 
>> Individual members of a union are mapped the same way as 
>> members of the
>> structure. That is, each of the members, if not a union, is 
>> mapped as if
>> it were a member of a structure.  This means that the first storage
>> locations for each of the members of a union do not overlay 
>> each other
>> if each of the members requires different alignment and therefore
>> different padding before the beginning of the member.
>> 
>> This violates C99 (6.7.2.1 p5)
>
>Not all compilers support C99, and of those that do not all of them
>conform to 100% of the requirements. The layout of structs and unions
>is an ABI issue, and it's quite possible that there are systems that
>can't afford to break the ABI for compatibility reasons.
>

Sure. I didn't have a copy of C90 handy, but I'd be willing to bet that
it had some similar requirement in there. I'm sure most compilers
conform to C90 given that they have had nearly 20 years to do so.


>

Mime
View raw message