[cxx-abi-dev] non-public non-static members vs POD layout
David Vandevoorde
daveed at edg.com
Tue Apr 29 01:07:23 UTC 2008
On Apr 28, 2008, at 6:59 PM, Mark Mitchell wrote:
> Scott --
>
> My personal opinion is that the ABI does not guarantee that "almost"
> PODs are laid out as PODs. In fact I think it says that such things
> must be laid out using the rules in the C++ ABI -- surprising though
> that might be.
>
> Also since the ABI predates TC1, the inclusion of pointers to
> members on PODs should not apply. I suppose the spec would
> explicitly say "PODs as defined prior to TC1"
>
> Does anyone object to making that change?
I think so. Hereunder is an e-mail to this list (from a few years
ago) that seems to indicate we already agreed to use the TC1
definition of PODs.
Daveed
Date: Mon, 25 Oct 2004 18:13:01 -0700
From: Mark Mitchell <mark at codesourcery.com>
Organization: CodeSourcery, LLC
To: Mark Mitchell <mark at codesourcery.com>
CC: Nathan Sidwell <nathan at codesourcery.com>,
Dennis Handly <dhandly at cup.hp.com>, cxx-abi-dev at codesourcery.com
Subject: Re: [cxx-abi-dev] What is a POD? TC1 or first C++ Standard
Mark Mitchell wrote:
> Yes, you're correct, the standard does guarantee that you can do
> bitwise copies for PODs using their size.
> In other words, your point is that unless we interpret the ABI as
> meaning "TC1 POD", it is not the ABI for a correct C++ compiler,
> because it will fall afoul of this rule. This is [basic.types]/3,
for
> reference.
>
> I think that's a pretty compelling agument that we should clarify the
> ABI to indicate that POD means "POD as defined by TC1". Any
> objections to that proposal? Are there any compilers other than aCC
> implementing the pre-TC1 definition?
Nobody objected, so I committed the following change, requiring the TC1
definition. The change will be reflected in the online copy shortly. I
also clarified the fact that an array that is a POD type, but whose
elements are not a POD for the purpose of layout is not itself a POD for
the purpose of layout.
FYI,
--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark at codesourcery.com
Index: abi.html
===================================================================
RCS file: /home/cvs/Repository/cxx-abi/abi.html,v
retrieving revision 1.78
diff -c -5 -p -r1.78 abi.html
*** abi.html 24 Sep 2004 03:47:55 -0000 1.78
--- abi.html 26 Oct 2004 01:09:26 -0000
*************** sharing a virtual pointer with the deriv
*** 228,242 ****
<p>
<a name="POD" />
<dt> <i>POD for the purpose of layout</i><dt>
<dd>
! A type is considered a POD for the purposes of layout if it is a POD
! type (in the sense of [basic.types]), and is not a POD-struct or
! POD-union (in the sense of [class]) with a bitfield member whose
declared
! width is wider than the declared type of the bitfield
! </dd>
</p>
<p>
<dt> <i>primary base class</i> </dt> <dd> For a dynamic class, the
unique base class (if any) with which it shares the virtual pointer at
--- 228,258 ----
<p>
<a name="POD" />
<dt> <i>POD for the purpose of layout</i><dt>
<dd>
! <p>
! In general, a type is considered a POD for the purposes of layout if
! it is a POD type (in the sense of ISO C++ [basic.types]). However, a
! POD-struct or POD-union (in the sense of ISO C++ [class]) with a
! bitfield member whose declared width is wider than the declared type
! of the bitfield is not a POD for the purpose of layout. Similarly, an
! array type is not a POD for the purpose of layout if the element type
! of the array is not a POD for the purpose of layout. Where references
! to the ISO C++ are made in this paragraph, the Technical Corrigendum 1
! version of the standard is intended.
!
! <p>
! <img src=warning.gif alt="<b>NOTE</b>:">
! The ISO C++ standard published in 1998 had a different definition of
! POD types. In particular, a class with a non-static data member of
! pointer-to-member type was not considered a POD in C++98, but is
! considered a POD in TC1. Because the C++ standard requires that
! compilers not overlay the tail padding in a POD, using the C++98
! definition in this ABI would prevent a conforming compiler from
! correctly implementing the TC1 version of the C++ standard.
! Therefore, this ABI uses the TC1 definition of POD.</dd>
</p>
<p>
<dt> <i>primary base class</i> </dt> <dd> For a dynamic class, the
unique base class (if any) with which it shares the virtual pointer at
*************** unwind table location.
*** 4939,4948 ****
--- 4955,4972 ----
<p> <hr> <p>
<p>This version of this document is $Revision: 1.78 $. No special
significance should be attached to the form of the revision number; it
is simply a identifying number.</p>
+
+ <p>
+ <font color=blue>[041025]</font>
+ Indicate that the TC1 definition of POD is intended in the section
+ defining a "POD for the purpose of layout". Clearly
+ indicate that an array whose elements are not PODs for the purpose of
+ layout is itself not a POD for the purpose of layout.
+ </p>
<p>
<font color=blue>[040923]</font>
Clarify behavior of <code>__cxa_vec_delete</code>.
</p>
More information about the cxx-abi-dev
mailing list