@@ -2062,7 +2062,7 @@ <h3><a href="#guards"> 2.8 Initialization Guard Variables </a></h3>
2062
2062
Usage of the other bytes of the guard variable is implementation-defined.
2063
2063
2064
2064
< p >
2065
- See < a href =#once-ctor > Section 3.3.2 </ a >
2065
+ See < a href =#once-ctor > Section 3.3.3 </ a >
2066
2066
for the API for references to this guard variable.
2067
2067
2068
2068
@@ -3160,10 +3160,11 @@ <h3><a href="#obj-ctor"> 3.3 Construction and Destruction APIs </a></h3>
3160
3160
This includes:
3161
3161
< ul >
3162
3162
< li > < a href =#subobj-ctor > 3.3.1 Subobject Construction and Destruction</ a >
3163
- < li > < a href =#once-ctor > 3.3.2 One-time Construction API </ a >
3164
- < li > < a href =#array-ctor > 3.3.3 Array Construction and Destruction API </ a >
3165
- < li > < a href =#ctor-order > 3.3.4 Controlling Object Construction Order </ a >
3166
- < li > < a href =#dso-dtor > 3.3.5 DSO Object Destruction API </ a >
3163
+ < li > < a href =#inh-ctor > 3.3.2 Construction by Inherited Constructor</ a >
3164
+ < li > < a href =#once-ctor > 3.3.3 One-time Construction API </ a >
3165
+ < li > < a href =#array-ctor > 3.3.4 Array Construction and Destruction API </ a >
3166
+ < li > < a href =#ctor-order > 3.3.5 Controlling Object Construction Order </ a >
3167
+ < li > < a href =#dso-dtor > 3.3.6 DSO Object Destruction API </ a >
3167
3168
</ ul >
3168
3169
3169
3170
@@ -3271,9 +3272,59 @@ <h4><a href="#subobj-ctor"> 3.3.1 Subobject Construction and Destruction </a></h
3271
3272
</ dl >
3272
3273
3273
3274
3275
+ < p >
3276
+ < a name ="inh-ctor "> </ a >
3277
+ < h4 > < a href ="#inh-ctor "> 3.3.2 Construction by Inherited Constructor</ a > </ h4 >
3278
+
3279
+ < p >
3280
+ A constructor inherited from a base class can be used to initialize a derived
3281
+ class object, if it is explicitly inherited by a < code > using</ code >
3282
+ declaration. Formally, such initialization is not performed by a derived class
3283
+ constructor, and instead the initialization expression itself directly
3284
+ initializes each base class (recursively, if the constructor is inherited from
3285
+ an indirect base class) and each non-static data member. To reduce code
3286
+ duplication, this ABI permits such initialization to be factored out into an
3287
+ < i > inheriting constructor</ i > function.
3288
+
3289
+ < p >
3290
+ An inheriting constructor describes the initialization that would be performed
3291
+ when a constructor inherited from a base class is selected to initialize a
3292
+ derived class, including the default-initialization of the other base classes
3293
+ and the non-static data members of the derived class. If the inheriting
3294
+ constructor is a base subobject constructor and the inherited constructor
3295
+ constructs a morally virtual base subobject, the inheriting constructor does
3296
+ not take any user-declared parameters; otherwise, it takes the same parameters
3297
+ as the inherited constructor. In all other respects, an inheriting constructors
3298
+ behaves the same as a constructor of the derived class. For example:
3299
+
3300
+ < code > < pre >
3301
+ struct X { X(); };
3302
+ struct A { A(int); };
3303
+ struct B : A { using A::A; };
3304
+ struct C : virtual B { using B::B; X x; };
3305
+ struct D : C { using C::C; };
3306
+ C c(0);
3307
+ D d(0);
3308
+
3309
+ // The initializations of c and d behave as if they call C::C< sub > complete A(int)</ sub > (0) and D::D< sub > complete A(int)</ sub > (0):
3310
+ D::D< sub > complete A(int)</ sub > (int n) : B< sub > base A(int)</ sub > (n), C< sub > base A(int)</ sub > () {} // _ZN1DCI11AEi
3311
+ C::C< sub > complete A(int)</ sub > (int n) : B< sub > base A(int)</ sub > (n), x() {} < sub > </ sub > // _ZN1CCI11AEi
3312
+ C::C< sub > base A(int)</ sub > () : /*no init for vbase B*/ x() {} < sub > </ sub > < sub > </ sub > // _ZN1CCI21AEi
3313
+ B::B< sub > base A(int)</ sub > (int n) : A(n) {} < sub > </ sub > < sub > </ sub > // _ZN1BCI21AEi
3314
+ </ pre > </ code >
3315
+
3316
+ < p >
3317
+ Inheriting constructors are not permitted to make copies of their parameters
3318
+ when passing them to the inherited constructor. If it would not be possible to
3319
+ transparently forward all parameters from the inheriting constructor to the
3320
+ inherited constructor, an inheriting constructor cannot be used, and a
3321
+ different implementation technique (such as emitting the initialization inline)
3322
+ must be used instead.
3323
+
3324
+
3274
3325
< p >
3275
3326
< a name ="once-ctor "> </ a >
3276
- < h4 > < a href ="#once-ctor "> 3.3.2 One-time Construction API </ a > </ h4 >
3327
+ < h4 > < a href ="#once-ctor "> 3.3.3 One-time Construction API </ a > </ h4 >
3277
3328
3278
3329
< p >
3279
3330
As described in < a href =#guards > Section 2.8</ a > , certain objects with
@@ -3403,7 +3454,7 @@ <h4><a href="#once-ctor"> 3.3.2 One-time Construction API </a></h4>
3403
3454
3404
3455
< p >
3405
3456
< a name ="array-ctor ">
3406
- < h4 > < a href ="#array-ctor "> 3.3.3 Array Construction and Destruction API </ a > </ h4 >
3457
+ < h4 > < a href ="#array-ctor "> 3.3.4 Array Construction and Destruction API </ a > </ h4 >
3407
3458
3408
3459
< p >
3409
3460
An ABI-compliant system shall provide several runtime routines for use
@@ -3649,11 +3700,11 @@ <h4><a href="#array-ctor"> 3.3.3 Array Construction and Destruction API </a></h4
3649
3700
3650
3701
< p >
3651
3702
< a name ="ctor-order ">
3652
- < h4 > < a href ="#ctor-order "> 3.3.4 Controlling Object Construction Order </ a > </ h4 >
3703
+ < h4 > < a href ="#ctor-order "> 3.3.5 Controlling Object Construction Order </ a > </ h4 >
3653
3704
3654
3705
< p >
3655
3706
< a name ="ctor-order-motivation ">
3656
- < h5 > < a href ="#ctor-order-motivation "> 3.3.4 .1 Motivation </ a > </ h5 >
3707
+ < h5 > < a href ="#ctor-order-motivation "> 3.3.5 .1 Motivation </ a > </ h5 >
3657
3708
3658
3709
< p >
3659
3710
< i >
@@ -3676,7 +3727,7 @@ <h5><a href="#ctor-order-motivation"> 3.3.4.1 Motivation </a></h5>
3676
3727
3677
3728
< p >
3678
3729
< a name ="ctor-order-pragma ">
3679
- < h5 > < a href ="#ctor-order-pragma "> 3.3.4 .2 Source Code API </ a > </ h5 >
3730
+ < h5 > < a href ="#ctor-order-pragma "> 3.3.5 .2 Source Code API </ a > </ h5 >
3680
3731
3681
3732
< p >
3682
3733
A user may specify the construction priority with the pragma:
@@ -3706,7 +3757,7 @@ <h5><a href="#ctor-order-pragma"> 3.3.4.2 Source Code API </a></h5>
3706
3757
3707
3758
< p >
3708
3759
< a name ="ctor-order-object-file ">
3709
- < h5 > < a href ="#ctor-order-object-file "> 3.3.4 .3 Object File Representation </ a > </ h5 >
3760
+ < h5 > < a href ="#ctor-order-object-file "> 3.3.5 .3 Object File Representation </ a > </ h5 >
3710
3761
3711
3762
< p >
3712
3763
Initialization priority is represented in the object file by elements
@@ -3744,7 +3795,7 @@ <h5><a href="#ctor-order-object-file"> 3.3.4.3 Object File Representation </a></
3744
3795
3745
3796
< p >
3746
3797
< a name ="ctor-order-runtime ">
3747
- < h5 > < a href ="#ctor-order-runtime "> 3.3.4 .4 Runtime Library Support </ a > </ h5 >
3798
+ < h5 > < a href ="#ctor-order-runtime "> 3.3.5 .4 Runtime Library Support </ a > </ h5 >
3748
3799
3749
3800
< p >
3750
3801
Each implementation supporting priority initialization shall provide
@@ -3760,7 +3811,7 @@ <h5><a href="#ctor-order-runtime"> 3.3.4.4 Runtime Library Support </a></h5>
3760
3811
3761
3812
< p >
3762
3813
< a name ="ctor-order-linker ">
3763
- < h5 > < a href ="#ctor-order-linker "> 3.3.4 .5 Linker Processing </ a > </ h5 >
3814
+ < h5 > < a href ="#ctor-order-linker "> 3.3.5 .5 Linker Processing </ a > </ h5 >
3764
3815
3765
3816
< p >
3766
3817
The only required static linker processing is to concatenate the
@@ -3804,11 +3855,11 @@ <h5><a href="#ctor-order-linker"> 3.3.4.5 Linker Processing </a></h5>
3804
3855
3805
3856
< p >
3806
3857
< a name ="dso-dtor ">
3807
- < h4 > < a href ="#dso-dtor "> 3.3.5 DSO Object Destruction API </ a > </ h4 >
3858
+ < h4 > < a href ="#dso-dtor "> 3.3.6 DSO Object Destruction API </ a > </ h4 >
3808
3859
3809
3860
< p >
3810
3861
< a name ="dso-dtor-motivation ">
3811
- < h5 > < a href ="#dso-dtor-motivation "> 3.3.5 .1 Motivation </ a > </ h5 >
3862
+ < h5 > < a href ="#dso-dtor-motivation "> 3.3.6 .1 Motivation </ a > </ h5 >
3812
3863
3813
3864
< p >
3814
3865
The C++ Standard requires that destructors be called for global objects
@@ -3832,7 +3883,7 @@ <h5><a href="#dso-dtor-motivation"> 3.3.5.1 Motivation </a></h5>
3832
3883
3833
3884
< p >
3834
3885
< a name ="dso-dtor-runtime-data ">
3835
- < h5 > < a href ="#dso-dtor-runtime-data "> 3.3.5 .2 Runtime Data Structure </ a > </ h5 >
3886
+ < h5 > < a href ="#dso-dtor-runtime-data "> 3.3.6 .2 Runtime Data Structure </ a > </ h5 >
3836
3887
3837
3888
< p >
3838
3889
The runtime library shall maintain a list of termination functions
@@ -3850,7 +3901,7 @@ <h5><a href="#dso-dtor-runtime-data"> 3.3.5.2 Runtime Data Structure </a></h5>
3850
3901
3851
3902
< p >
3852
3903
< a name ="dso-dtor-runtime-api ">
3853
- < h5 > < a href ="#dso-dtor-runtime-api "> 3.3.5 .3 Runtime API </ a > </ h5 >
3904
+ < h5 > < a href ="#dso-dtor-runtime-api "> 3.3.6 .3 Runtime API </ a > </ h5 >
3854
3905
3855
3906
< ol type =A >
3856
3907
< p >
@@ -4510,15 +4561,25 @@ <h5><a href="#mangling-special-ctor-dtor"> 5.1.4.3 Constructors and Destructors
4510
4561
is replaced by one of the following:
4511
4562
4512
4563
< pre > < font color =blue > < code >
4513
- << a name ="mangle.ctor-dtor-name "> ctor-dtor-name</ a > > ::= C1 # complete object constructor
4514
- ::= C2 # base object constructor
4515
- ::= C3 # complete object allocating constructor
4516
- ::= D0 # deleting destructor
4517
- ::= D1 # complete object destructor
4518
- ::= D2 # base object destructor
4519
-
4564
+ << a name ="mangle.ctor-dtor-name "> ctor-dtor-name</ a > > ::= C1 # complete object constructor
4565
+ ::= C2 # base object constructor
4566
+ ::= C3 # complete object allocating constructor
4567
+ ::= CI1 << i > base class</ i > < a href ="#mangle.type "> type</ a > > # complete object < a href ="#inh-ctor "> inheriting constructor</ a >
4568
+ ::= CI2 << i > base class</ i > < a href ="#mangle.type "> type</ a > > # base object < a href ="#inh-ctor "> inheriting constructor</ a >
4569
+ ::= D0 # deleting destructor
4570
+ ::= D1 # complete object destructor
4571
+ ::= D2 # base object destructor
4520
4572
</ pre > </ font > </ code >
4521
4573
4574
+ < p >
4575
+ The << i > base class</ i > < a href ="#mangle.type "> type</ a > > in an inheriting
4576
+ constructor mangling identifies the base class in which the inherited
4577
+ constructor was originally declared.
4578
+
4579
+ < p >
4580
+ Some of the symbols for constructor and destructor variants are < a
4581
+ href ="#vague-ctor "> optional</ a > .
4582
+
4522
4583
< p >
4523
4584
< a name ="mangling-special-guards ">
4524
4585
< h5 > < a href ="#mangling-special-guards "> 5.1.4.4 Guard Variables </ a > </ h5 >
@@ -5912,7 +5973,7 @@ <h4><a href="#vague-static"> 5.2.2 Static Data </a></h4>
5912
5973
< p >
5913
5974
Some objects with static storage duration have associated guard variables
5914
5975
used to ensure that they are initialized only once
5915
- (see < a href =once-ctor > 3.3.2 </ a > ).
5976
+ (see < a href =once-ctor > 3.3.3 </ a > ).
5916
5977
If the object is emitted using a COMDAT group,
5917
5978
the guard variable must be too.
5918
5979
It is suggested that it be emitted in the same COMDAT group as the
@@ -5996,12 +6057,13 @@ <h4><a href="#vague-ctor"> 5.2.5 Constructors and Destructors</a></h4>
5996
6057
or destructor name.
5997
6058
5998
6059
< p >
5999
- This ABI does not require the generation or use of allocating
6000
- constructors or deleting destructors for classes without a virtual
6001
- destructor. However, if an implementation emits such functions, it
6002
- must use the external names specified in this ABI. If such a function
6003
- has external linkage, it must be emitted wherever referenced, in a
6004
- COMDAT group whose name is the external name of the function.
6060
+ This ABI does not require the generation or use of allocating constructors or
6061
+ inheriting constructors, and does not require the generation or use of deleting
6062
+ destructors for classes without a virtual destructor. However, if an
6063
+ implementation emits such functions, it must use the external names specified
6064
+ in this ABI. If such a function has external linkage, it must be emitted
6065
+ wherever referenced, in a COMDAT group whose name is the external name of the
6066
+ function.
6005
6067
6006
6068
< p >
6007
6069
< a name ="vague-itemplate ">
@@ -6328,32 +6390,32 @@ <h2><a name="revisions">Appendix R: Revision History</a></h2>
6328
6390
Note about locating virtual bases statically during
6329
6391
construction (2.6.1).
6330
6392
Rename IA-64 to Itanium throughout.
6331
- Add __cxa_vec_cleanup (3.3.3 ).</ p >
6393
+ Add __cxa_vec_cleanup (3.3.4 ).</ p >
6332
6394
6333
6395
< p class ="revision "> < span class ="date "> [000817]</ span >
6334
6396
Updates from 17 August meeting, email.</ p >
6335
6397
6336
6398
< p class ="revision "> < span class ="date "> [000807]</ span >
6337
6399
Added base document section (1.5).
6338
6400
Further RTTI field name cleanup (2.9.4).
6339
- Update proposed one-time construction API (3.3.2 ).
6340
- Update proposed object construction priority API (3.3.4 ).
6401
+ Update proposed one-time construction API (3.3.3 ).
6402
+ Update proposed object construction priority API (3.3.5 ).
6341
6403
Removed <name> substitution (5.1.2).
6342
6404
COMDAT not generally necessary for internal linkage (5.2).
6343
6405
COMDAT for local static guard variables (5.2.2).</ p >
6344
6406
6345
6407
< p class ="revision "> < span class ="date "> [000727]</ span >
6346
6408
Updates from 20 July meeting.
6347
- Added section on controlling object construction order (3.3.4 ).</ p >
6409
+ Added section on controlling object construction order (3.3.5 ).</ p >
6348
6410
6349
6411
< p class ="revision "> < span class ="date "> [000707]</ span >
6350
6412
Introduce consistent type_info field names (2.9.4).
6351
6413
Removed vmi flags for publicly/non-publicly inherited bases (2.9.4).
6352
6414
Collect all construction/destruction APIs in one section (3.3).
6353
- Added one-time initialization API (3.3.2 ).
6354
- Vector construction/destruction routines are extern "C" (3.3.3 ).
6355
- Added routines for vector construction/destruction (3.3.3 ).
6356
- Added copy construction runtime API (3.3.3 ).
6415
+ Added one-time initialization API (3.3.3 ).
6416
+ Vector construction/destruction routines are extern "C" (3.3.4 ).
6417
+ Added routines for vector construction/destruction (3.3.4 ).
6418
+ Added copy construction runtime API (3.3.4 ).
6357
6419
Make Alex's changes in mangling grammar (5.1).
6358
6420
Add <special-name> cases for covariant override thunks (5.1.4).
6359
6421
Allow expressions as array type dimensions (5.1.5).
0 commit comments