- tmp/tmp3fdpegqq/{from.md → to.md} +143 -150
tmp/tmp3fdpegqq/{from.md → to.md}
RENAMED
|
@@ -1,27 +1,25 @@
|
|
| 1 |
### Start and termination <a id="basic.start">[[basic.start]]</a>
|
| 2 |
|
| 3 |
#### `main` function <a id="basic.start.main">[[basic.start.main]]</a>
|
| 4 |
|
| 5 |
-
A program shall contain
|
| 6 |
-
global
|
| 7 |
-
[[intro.multithread]], [[thread.threads]]
|
| 8 |
-
is invoked
|
| 9 |
-
|
| 10 |
-
It is *implementation-defined* whether a program in a freestanding
|
| 11 |
-
environment is required to define a `main` function.
|
| 12 |
|
| 13 |
[*Note 1*: In a freestanding environment, startup and termination is
|
| 14 |
*implementation-defined*; startup contains the execution of constructors
|
| 15 |
-
for objects
|
| 16 |
-
|
| 17 |
duration. — *end note*]
|
| 18 |
|
| 19 |
-
An implementation shall not predefine the `main` function.
|
| 20 |
-
shall
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
- a function of `()` returning `int` and
|
| 25 |
- a function of `(int`, pointer to pointer to `char)` returning `int`
|
| 26 |
|
| 27 |
as the type of `main` [[dcl.fct]]. In the latter form, for purposes of
|
|
@@ -34,33 +32,37 @@ characters of null-terminated multibyte strings (NTMBSs)
|
|
| 34 |
[[multibyte.strings]] and `argv[0]` shall be the pointer to the initial
|
| 35 |
character of a NTMBS that represents the name used to invoke the program
|
| 36 |
or `""`. The value of `argc` shall be non-negative. The value of
|
| 37 |
`argv[argc]` shall be 0.
|
| 38 |
|
| 39 |
-
|
| 40 |
-
added after `argv`.
|
| 41 |
|
| 42 |
The function `main` shall not be used within a program. The linkage
|
| 43 |
[[basic.link]] of `main` is *implementation-defined*. A program that
|
| 44 |
defines `main` as deleted or that declares `main` to be `inline`,
|
| 45 |
-
`static`, or `
|
| 46 |
-
a coroutine [[dcl.fct.def.coroutine]]. The `main` function
|
| 47 |
-
declared with a *linkage-specification* [[dcl.link]]. A
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
[*Example 1*: Member functions, classes, and enumerations can be called
|
| 54 |
`main`, as can entities in other namespaces. — *end example*]
|
| 55 |
|
| 56 |
Terminating the program without leaving the current block (e.g., by
|
| 57 |
calling the function `std::exit(int)` [[support.start.term]]) does not
|
| 58 |
destroy any objects with automatic storage duration [[class.dtor]]. If
|
| 59 |
-
`std::exit` is
|
| 60 |
-
|
| 61 |
-
behavior.
|
| 62 |
|
| 63 |
A `return` statement [[stmt.return]] in `main` has the effect of leaving
|
| 64 |
the main function (destroying any objects with automatic storage
|
| 65 |
duration) and calling `std::exit` with the return value as the argument.
|
| 66 |
If control flows off the end of the *compound-statement* of `main`, the
|
|
@@ -78,16 +80,16 @@ phases of initiation, initialization occurs as follows.
|
|
| 78 |
with static or thread storage duration is constant-initialized
|
| 79 |
[[expr.const]]. If constant initialization is not performed, a variable
|
| 80 |
with static storage duration [[basic.stc.static]] or thread storage
|
| 81 |
duration [[basic.stc.thread]] is zero-initialized [[dcl.init]].
|
| 82 |
Together, zero-initialization and constant initialization are called
|
| 83 |
-
*static initialization*; all other initialization is
|
| 84 |
-
initialization*. All static initialization strongly happens
|
| 85 |
-
[[intro.races]] any dynamic initialization.
|
| 86 |
|
| 87 |
-
[*Note 1*: The dynamic initialization of non-
|
| 88 |
-
described in [[basic.start.dynamic]]; that of
|
| 89 |
described in [[stmt.dcl]]. — *end note*]
|
| 90 |
|
| 91 |
An implementation is permitted to perform the initialization of a
|
| 92 |
variable with static or thread storage duration as a static
|
| 93 |
initialization even if such initialization is not required to be done
|
|
@@ -102,49 +104,48 @@ statically, provided that
|
|
| 102 |
statically were initialized dynamically.
|
| 103 |
|
| 104 |
[*Note 2*:
|
| 105 |
|
| 106 |
As a consequence, if the initialization of an object `obj1` refers to an
|
| 107 |
-
object `obj2`
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
|
| 113 |
``` cpp
|
| 114 |
inline double fd() { return 1.0; }
|
| 115 |
extern double d1;
|
| 116 |
double d2 = d1; // unspecified:
|
| 117 |
-
//
|
| 118 |
// dynamically initialized to 0.0 if d1 is
|
| 119 |
// dynamically initialized, or 1.0 otherwise
|
| 120 |
-
double d1 = fd(); //
|
| 121 |
```
|
| 122 |
|
| 123 |
— *end note*]
|
| 124 |
|
| 125 |
-
#### Dynamic initialization of non-
|
| 126 |
|
| 127 |
-
Dynamic initialization of a non-
|
| 128 |
duration is unordered if the variable is an implicitly or explicitly
|
| 129 |
instantiated specialization, is partially-ordered if the variable is an
|
| 130 |
inline variable that is not an implicitly or explicitly instantiated
|
| 131 |
specialization, and otherwise is ordered.
|
| 132 |
|
| 133 |
-
[*Note 1*:
|
| 134 |
-
|
| 135 |
-
initialization. — *end note*]
|
| 136 |
|
| 137 |
A declaration `D` is *appearance-ordered* before a declaration `E` if
|
| 138 |
|
| 139 |
- `D` appears in the same translation unit as `E`, or
|
| 140 |
- the translation unit containing `E` has an interface dependency on the
|
| 141 |
translation unit containing `D`,
|
| 142 |
|
| 143 |
in either case prior to `E`.
|
| 144 |
|
| 145 |
-
Dynamic initialization of non-
|
| 146 |
storage duration are ordered as follows:
|
| 147 |
|
| 148 |
- If `V` and `W` have ordered initialization and the definition of `V`
|
| 149 |
is appearance-ordered before the definition of `W`, or if `V` has
|
| 150 |
partially-ordered initialization, `W` does not have unordered
|
|
@@ -166,25 +167,26 @@ storage duration are ordered as follows:
|
|
| 166 |
sequenced.
|
| 167 |
|
| 168 |
[*Note 2*: This definition permits initialization of a sequence of
|
| 169 |
ordered variables concurrently with another sequence. — *end note*]
|
| 170 |
|
| 171 |
-
A *non-initialization odr-use* is an odr-use [[
|
| 172 |
-
|
| 173 |
-
|
| 174 |
|
| 175 |
It is *implementation-defined* whether the dynamic initialization of a
|
| 176 |
-
non-
|
| 177 |
before the first statement of `main` or is deferred. If it is deferred,
|
| 178 |
it strongly happens before any non-initialization odr-use of any
|
| 179 |
non-inline function or non-inline variable defined in the same
|
| 180 |
-
translation unit as the variable to be initialized.
|
| 181 |
-
*implementation-defined* in which threads and at which points in the
|
| 182 |
-
program such deferred dynamic initialization occurs.
|
| 183 |
|
| 184 |
-
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
[*Example 1*:
|
| 188 |
|
| 189 |
``` cpp
|
| 190 |
// - File 1 -
|
|
@@ -221,27 +223,27 @@ point after the first statement of `main`, `b` will be initialized prior
|
|
| 221 |
to its use in `A::A`.
|
| 222 |
|
| 223 |
— *end example*]
|
| 224 |
|
| 225 |
It is *implementation-defined* whether the dynamic initialization of a
|
| 226 |
-
non-
|
| 227 |
before the first statement of `main` or is deferred. If it is deferred,
|
| 228 |
it strongly happens before any non-initialization odr-use of that
|
| 229 |
variable. It is *implementation-defined* in which threads and at which
|
| 230 |
points in the program such deferred dynamic initialization occurs.
|
| 231 |
|
| 232 |
It is *implementation-defined* whether the dynamic initialization of a
|
| 233 |
-
non-
|
| 234 |
before the first statement of the initial function of a thread or is
|
| 235 |
deferred. If it is deferred, the initialization associated with the
|
| 236 |
entity for thread *t* is sequenced before the first non-initialization
|
| 237 |
odr-use by *t* of any non-inline variable with thread storage duration
|
| 238 |
defined in the same translation unit as the variable to be initialized.
|
| 239 |
It is *implementation-defined* in which threads and at which points in
|
| 240 |
the program such deferred dynamic initialization occurs.
|
| 241 |
|
| 242 |
-
If the initialization of a non-
|
| 243 |
storage duration exits via an exception, the function `std::terminate`
|
| 244 |
is called [[except.terminate]].
|
| 245 |
|
| 246 |
#### Termination <a id="basic.start.term">[[basic.start.term]]</a>
|
| 247 |
|
|
@@ -268,23 +270,25 @@ of the constructor or dynamic initialization of an object with thread
|
|
| 268 |
storage duration is sequenced before that of another, the completion of
|
| 269 |
the destructor of the second is sequenced before the initiation of the
|
| 270 |
destructor of the first. If an object is initialized statically, the
|
| 271 |
object is destroyed in the same order as if the object was dynamically
|
| 272 |
initialized. For an object of array or class type, all subobjects of
|
| 273 |
-
that object are destroyed before any block
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
|
| 279 |
-
If a function contains a block
|
| 280 |
duration that has been destroyed and the function is called during the
|
| 281 |
destruction of an object with static or thread storage duration, the
|
| 282 |
program has undefined behavior if the flow of control passes through the
|
| 283 |
-
definition of the previously destroyed block
|
| 284 |
-
|
| 285 |
-
|
|
|
|
|
|
|
| 286 |
|
| 287 |
If the completion of the initialization of an object with static storage
|
| 288 |
duration strongly happens before a call to `std::atexit` (see
|
| 289 |
`<cstdlib>`, [[support.start.term]]), the call to the function passed to
|
| 290 |
`std::atexit` is sequenced before the call to the destructor for the
|
|
@@ -301,11 +305,11 @@ If there is a use of a standard library object or function not permitted
|
|
| 301 |
within signal handlers [[support.runtime]] that does not happen before
|
| 302 |
[[intro.multithread]] completion of destruction of objects with static
|
| 303 |
storage duration and execution of `std::atexit` registered functions
|
| 304 |
[[support.start.term]], the program has undefined behavior.
|
| 305 |
|
| 306 |
-
[*Note
|
| 307 |
that does not happen before the object’s destruction, the program has
|
| 308 |
undefined behavior. Terminating every thread before a call to
|
| 309 |
`std::exit` or the exit from `main` is sufficient, but not necessary, to
|
| 310 |
satisfy these requirements. These requirements permit thread managers as
|
| 311 |
static-storage-duration objects. — *end note*]
|
|
@@ -313,49 +317,50 @@ static-storage-duration objects. — *end note*]
|
|
| 313 |
Calling the function `std::abort()` declared in `<cstdlib>` terminates
|
| 314 |
the program without executing any destructors and without calling the
|
| 315 |
functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
| 316 |
|
| 317 |
<!-- Link reference definitions -->
|
| 318 |
-
[allocator.members]:
|
| 319 |
-
[allocator.traits.members]:
|
| 320 |
-
[atomics]:
|
| 321 |
-
[atomics.flag]:
|
| 322 |
-
[atomics.lockfree]:
|
| 323 |
-
[atomics.order]:
|
| 324 |
[bad.alloc]: support.md#bad.alloc
|
| 325 |
[basic]: #basic
|
| 326 |
[basic.align]: #basic.align
|
| 327 |
[basic.compound]: #basic.compound
|
| 328 |
[basic.def]: #basic.def
|
| 329 |
[basic.def.odr]: #basic.def.odr
|
| 330 |
[basic.exec]: #basic.exec
|
|
|
|
| 331 |
[basic.fundamental]: #basic.fundamental
|
| 332 |
[basic.fundamental.width]: #basic.fundamental.width
|
| 333 |
-
[basic.funscope]: #basic.funscope
|
| 334 |
[basic.indet]: #basic.indet
|
| 335 |
[basic.life]: #basic.life
|
| 336 |
[basic.link]: #basic.link
|
| 337 |
[basic.lookup]: #basic.lookup
|
| 338 |
[basic.lookup.argdep]: #basic.lookup.argdep
|
| 339 |
-
[basic.lookup.classref]: #basic.lookup.classref
|
| 340 |
[basic.lookup.elab]: #basic.lookup.elab
|
|
|
|
| 341 |
[basic.lookup.qual]: #basic.lookup.qual
|
|
|
|
| 342 |
[basic.lookup.udir]: #basic.lookup.udir
|
| 343 |
[basic.lookup.unqual]: #basic.lookup.unqual
|
| 344 |
[basic.lval]: expr.md#basic.lval
|
| 345 |
[basic.memobj]: #basic.memobj
|
| 346 |
[basic.namespace]: dcl.md#basic.namespace
|
| 347 |
[basic.pre]: #basic.pre
|
| 348 |
[basic.scope]: #basic.scope
|
| 349 |
[basic.scope.block]: #basic.scope.block
|
| 350 |
[basic.scope.class]: #basic.scope.class
|
| 351 |
-
[basic.scope.declarative]: #basic.scope.declarative
|
| 352 |
[basic.scope.enum]: #basic.scope.enum
|
| 353 |
-
[basic.scope.
|
| 354 |
[basic.scope.namespace]: #basic.scope.namespace
|
| 355 |
[basic.scope.param]: #basic.scope.param
|
| 356 |
[basic.scope.pdecl]: #basic.scope.pdecl
|
|
|
|
| 357 |
[basic.scope.temp]: #basic.scope.temp
|
| 358 |
[basic.start]: #basic.start
|
| 359 |
[basic.start.dynamic]: #basic.start.dynamic
|
| 360 |
[basic.start.main]: #basic.start.main
|
| 361 |
[basic.start.static]: #basic.start.static
|
|
@@ -363,22 +368,25 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 363 |
[basic.stc]: #basic.stc
|
| 364 |
[basic.stc.auto]: #basic.stc.auto
|
| 365 |
[basic.stc.dynamic]: #basic.stc.dynamic
|
| 366 |
[basic.stc.dynamic.allocation]: #basic.stc.dynamic.allocation
|
| 367 |
[basic.stc.dynamic.deallocation]: #basic.stc.dynamic.deallocation
|
| 368 |
-
[basic.stc.dynamic.
|
|
|
|
| 369 |
[basic.stc.inherit]: #basic.stc.inherit
|
| 370 |
[basic.stc.static]: #basic.stc.static
|
| 371 |
[basic.stc.thread]: #basic.stc.thread
|
| 372 |
[basic.type.qualifier]: #basic.type.qualifier
|
| 373 |
[basic.type.qualifier.rel]: #basic.type.qualifier.rel
|
| 374 |
[basic.types]: #basic.types
|
| 375 |
-
[
|
| 376 |
-
[
|
|
|
|
| 377 |
[class]: class.md#class
|
| 378 |
[class.abstract]: class.md#class.abstract
|
| 379 |
[class.access]: class.md#class.access
|
|
|
|
| 380 |
[class.base.init]: class.md#class.base.init
|
| 381 |
[class.bit]: class.md#class.bit
|
| 382 |
[class.cdtor]: class.md#class.cdtor
|
| 383 |
[class.conv.fct]: class.md#class.conv.fct
|
| 384 |
[class.copy.assign]: class.md#class.copy.assign
|
|
@@ -387,26 +395,24 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 387 |
[class.default.ctor]: class.md#class.default.ctor
|
| 388 |
[class.derived]: class.md#class.derived
|
| 389 |
[class.dtor]: class.md#class.dtor
|
| 390 |
[class.free]: class.md#class.free
|
| 391 |
[class.friend]: class.md#class.friend
|
| 392 |
-
[class.local]: class.md#class.local
|
| 393 |
[class.mem]: class.md#class.mem
|
| 394 |
-
[class.member.lookup]:
|
| 395 |
[class.mfct]: class.md#class.mfct
|
| 396 |
-
[class.mfct.non
|
| 397 |
[class.name]: class.md#class.name
|
| 398 |
-
[class.nest]: class.md#class.nest
|
| 399 |
[class.pre]: class.md#class.pre
|
| 400 |
[class.prop]: class.md#class.prop
|
| 401 |
[class.qual]: #class.qual
|
| 402 |
[class.spaceship]: class.md#class.spaceship
|
| 403 |
[class.static]: class.md#class.static
|
| 404 |
[class.static.data]: class.md#class.static.data
|
| 405 |
[class.temporary]: #class.temporary
|
| 406 |
-
[class.this]: class.md#class.this
|
| 407 |
[class.union]: class.md#class.union
|
|
|
|
| 408 |
[class.virtual]: class.md#class.virtual
|
| 409 |
[conv]: expr.md#conv
|
| 410 |
[conv.array]: expr.md#conv.array
|
| 411 |
[conv.func]: expr.md#conv.func
|
| 412 |
[conv.integral]: expr.md#conv.integral
|
|
@@ -434,11 +440,10 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 434 |
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 435 |
[dcl.init]: dcl.md#dcl.init
|
| 436 |
[dcl.init.aggr]: dcl.md#dcl.init.aggr
|
| 437 |
[dcl.init.list]: dcl.md#dcl.init.list
|
| 438 |
[dcl.init.ref]: dcl.md#dcl.init.ref
|
| 439 |
-
[dcl.inline]: dcl.md#dcl.inline
|
| 440 |
[dcl.link]: dcl.md#dcl.link
|
| 441 |
[dcl.meaning]: dcl.md#dcl.meaning
|
| 442 |
[dcl.mptr]: dcl.md#dcl.mptr
|
| 443 |
[dcl.name]: dcl.md#dcl.name
|
| 444 |
[dcl.pre]: dcl.md#dcl.pre
|
|
@@ -446,34 +451,31 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 446 |
[dcl.ref]: dcl.md#dcl.ref
|
| 447 |
[dcl.spec]: dcl.md#dcl.spec
|
| 448 |
[dcl.spec.auto]: dcl.md#dcl.spec.auto
|
| 449 |
[dcl.stc]: dcl.md#dcl.stc
|
| 450 |
[dcl.struct.bind]: dcl.md#dcl.struct.bind
|
|
|
|
| 451 |
[dcl.type.elab]: dcl.md#dcl.type.elab
|
| 452 |
[dcl.typedef]: dcl.md#dcl.typedef
|
| 453 |
[defns.block]: intro.md#defns.block
|
| 454 |
-
[defns.signature]: intro.md#defns.signature
|
| 455 |
-
[defns.signature.templ]: intro.md#defns.signature.templ
|
| 456 |
[depr.local]: future.md#depr.local
|
| 457 |
[depr.static.constexpr]: future.md#depr.static.constexpr
|
| 458 |
[diff.cpp11.basic]: compatibility.md#diff.cpp11.basic
|
| 459 |
[enum.udecl]: dcl.md#enum.udecl
|
| 460 |
[except.handle]: except.md#except.handle
|
| 461 |
[except.pre]: except.md#except.pre
|
| 462 |
[except.spec]: except.md#except.spec
|
| 463 |
[except.terminate]: except.md#except.terminate
|
| 464 |
[except.throw]: except.md#except.throw
|
| 465 |
-
[expr]: expr.md#expr
|
| 466 |
[expr.add]: expr.md#expr.add
|
| 467 |
[expr.alignof]: expr.md#expr.alignof
|
| 468 |
[expr.arith.conv]: expr.md#expr.arith.conv
|
| 469 |
[expr.ass]: expr.md#expr.ass
|
| 470 |
[expr.await]: expr.md#expr.await
|
| 471 |
[expr.call]: expr.md#expr.call
|
| 472 |
[expr.cast]: expr.md#expr.cast
|
| 473 |
[expr.comma]: expr.md#expr.comma
|
| 474 |
-
[expr.compound]: expr.md#expr.compound
|
| 475 |
[expr.cond]: expr.md#expr.cond
|
| 476 |
[expr.const]: expr.md#expr.const
|
| 477 |
[expr.const.cast]: expr.md#expr.const.cast
|
| 478 |
[expr.context]: expr.md#expr.context
|
| 479 |
[expr.delete]: expr.md#expr.delete
|
|
@@ -483,12 +485,12 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 483 |
[expr.log.or]: expr.md#expr.log.or
|
| 484 |
[expr.mptr.oper]: expr.md#expr.mptr.oper
|
| 485 |
[expr.new]: expr.md#expr.new
|
| 486 |
[expr.pre]: expr.md#expr.pre
|
| 487 |
[expr.prim.id]: expr.md#expr.prim.id
|
| 488 |
-
[expr.prim.id.dtor]: expr.md#expr.prim.id.dtor
|
| 489 |
[expr.prim.id.qual]: expr.md#expr.prim.id.qual
|
|
|
|
| 490 |
[expr.prim.lambda]: expr.md#expr.prim.lambda
|
| 491 |
[expr.prim.lambda.capture]: expr.md#expr.prim.lambda.capture
|
| 492 |
[expr.prim.lambda.closure]: expr.md#expr.prim.lambda.closure
|
| 493 |
[expr.prim.this]: expr.md#expr.prim.this
|
| 494 |
[expr.prop]: expr.md#expr.prop
|
|
@@ -504,184 +506,175 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 504 |
[get.new.handler]: support.md#get.new.handler
|
| 505 |
[headers]: library.md#headers
|
| 506 |
[intro.execution]: #intro.execution
|
| 507 |
[intro.memory]: #intro.memory
|
| 508 |
[intro.multithread]: #intro.multithread
|
|
|
|
| 509 |
[intro.object]: #intro.object
|
| 510 |
[intro.progress]: #intro.progress
|
| 511 |
[intro.races]: #intro.races
|
| 512 |
[lex.charset]: lex.md#lex.charset
|
|
|
|
| 513 |
[lex.name]: lex.md#lex.name
|
| 514 |
[lex.separate]: lex.md#lex.separate
|
| 515 |
-
[locale]: localization.md#locale
|
| 516 |
-
[meta.trans.other]: utilities.md#meta.trans.other
|
| 517 |
[module.context]: module.md#module.context
|
| 518 |
[module.global.frag]: module.md#module.global.frag
|
| 519 |
-
[module.import]: module.md#module.import
|
| 520 |
[module.interface]: module.md#module.interface
|
| 521 |
[module.reach]: module.md#module.reach
|
| 522 |
[module.unit]: module.md#module.unit
|
| 523 |
[multibyte.strings]: library.md#multibyte.strings
|
| 524 |
[namespace.def]: dcl.md#namespace.def
|
| 525 |
-
[namespace.memdef]: dcl.md#namespace.memdef
|
| 526 |
[namespace.qual]: #namespace.qual
|
| 527 |
[namespace.udecl]: dcl.md#namespace.udecl
|
| 528 |
[namespace.udir]: dcl.md#namespace.udir
|
|
|
|
| 529 |
[new.delete]: support.md#new.delete
|
| 530 |
[new.delete.array]: support.md#new.delete.array
|
| 531 |
[new.delete.placement]: support.md#new.delete.placement
|
| 532 |
[new.delete.single]: support.md#new.delete.single
|
| 533 |
[new.handler]: support.md#new.handler
|
|
|
|
|
|
|
| 534 |
[over]: over.md#over
|
| 535 |
[over.literal]: over.md#over.literal
|
| 536 |
[over.match]: over.md#over.match
|
|
|
|
| 537 |
[over.oper]: over.md#over.oper
|
| 538 |
[over.over]: over.md#over.over
|
| 539 |
-
[ptr.align]:
|
| 540 |
[ptr.launder]: support.md#ptr.launder
|
| 541 |
[replacement.functions]: library.md#replacement.functions
|
| 542 |
[special]: class.md#special
|
|
|
|
|
|
|
| 543 |
[stmt.block]: stmt.md#stmt.block
|
| 544 |
[stmt.dcl]: stmt.md#stmt.dcl
|
| 545 |
[stmt.expr]: stmt.md#stmt.expr
|
| 546 |
-
[stmt.goto]: stmt.md#stmt.goto
|
| 547 |
[stmt.if]: stmt.md#stmt.if
|
| 548 |
-
[stmt.
|
|
|
|
| 549 |
[stmt.ranged]: stmt.md#stmt.ranged
|
| 550 |
[stmt.return]: stmt.md#stmt.return
|
|
|
|
| 551 |
[support.dynamic]: support.md#support.dynamic
|
| 552 |
-
[support.limits]: support.md#support.limits
|
| 553 |
[support.runtime]: support.md#support.runtime
|
| 554 |
[support.start.term]: support.md#support.start.term
|
| 555 |
[support.types]: support.md#support.types
|
|
|
|
| 556 |
[temp.deduct.guide]: temp.md#temp.deduct.guide
|
| 557 |
[temp.dep]: temp.md#temp.dep
|
| 558 |
[temp.dep.candidate]: temp.md#temp.dep.candidate
|
|
|
|
|
|
|
| 559 |
[temp.expl.spec]: temp.md#temp.expl.spec
|
| 560 |
[temp.explicit]: temp.md#temp.explicit
|
|
|
|
| 561 |
[temp.local]: temp.md#temp.local
|
| 562 |
[temp.names]: temp.md#temp.names
|
| 563 |
-
[temp.nondep]: temp.md#temp.nondep
|
| 564 |
[temp.over]: temp.md#temp.over
|
|
|
|
| 565 |
[temp.param]: temp.md#temp.param
|
| 566 |
[temp.point]: temp.md#temp.point
|
| 567 |
[temp.pre]: temp.md#temp.pre
|
| 568 |
[temp.res]: temp.md#temp.res
|
| 569 |
[temp.spec]: temp.md#temp.spec
|
|
|
|
| 570 |
[temp.type]: temp.md#temp.type
|
|
|
|
|
|
|
|
|
|
| 571 |
[thread]: thread.md#thread
|
| 572 |
[thread.jthread.class]: thread.md#thread.jthread.class
|
| 573 |
[thread.thread.class]: thread.md#thread.thread.class
|
| 574 |
[thread.threads]: thread.md#thread.threads
|
| 575 |
-
[util.dynamic.safety]: utilities.md#util.dynamic.safety
|
| 576 |
|
| 577 |
[^1]: Appearing inside the brace-enclosed *declaration-seq* in a
|
| 578 |
*linkage-specification* does not affect whether a declaration is a
|
| 579 |
definition.
|
| 580 |
|
| 581 |
[^2]: An implementation is not required to call allocation and
|
| 582 |
deallocation functions from constructors or destructors; however,
|
| 583 |
this is a permissible implementation technique.
|
| 584 |
|
| 585 |
-
[^3]:
|
| 586 |
-
|
| 587 |
-
used in the function body.
|
| 588 |
|
| 589 |
-
[^4]:
|
| 590 |
-
name may be used in a *base-specifier* or in the
|
| 591 |
-
*member-specification* of the class definition.
|
| 592 |
-
|
| 593 |
-
[^5]: This lookup applies whether the definition of `X` is nested within
|
| 594 |
-
`Y`’s definition or whether `X`’s definition appears in a namespace
|
| 595 |
-
scope enclosing `Y`’s definition [[class.nest]].
|
| 596 |
-
|
| 597 |
-
[^6]: That is, an unqualified name that occurs, for instance, in a type
|
| 598 |
-
in the *parameter-declaration-clause* or in the
|
| 599 |
-
*noexcept-specifier*.
|
| 600 |
-
|
| 601 |
-
[^7]: This lookup applies whether the member function is defined within
|
| 602 |
-
the definition of class `X` or whether the member function is
|
| 603 |
-
defined in a namespace scope enclosing `X`’s definition.
|
| 604 |
-
|
| 605 |
-
[^8]: Lookups in which function names are ignored include names
|
| 606 |
appearing in a *nested-name-specifier*, an
|
| 607 |
*elaborated-type-specifier*, or a *base-specifier*.
|
| 608 |
|
| 609 |
-
[^
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 610 |
in the header `<climits>`.
|
| 611 |
|
| 612 |
-
[^
|
| 613 |
objects at the same machine address or not store an object at all if
|
| 614 |
the program cannot observe the difference [[intro.execution]].
|
| 615 |
|
| 616 |
-
[^
|
| 617 |
-
|
| 618 |
|
| 619 |
-
[^
|
| 620 |
implicitly—upon exit from the block for an object with automatic
|
| 621 |
storage duration, upon exit from the thread for an object with
|
| 622 |
thread storage duration, or upon exit from the program for an object
|
| 623 |
with static storage duration.
|
| 624 |
|
| 625 |
-
[^
|
| 626 |
value causes a system-generated runtime fault.
|
| 627 |
|
| 628 |
-
[^
|
| 629 |
`std::malloc()` or `std::calloc()`, so the rules are substantially
|
| 630 |
the same. C++ differs from C in requiring a zero request to return a
|
| 631 |
non-null pointer.
|
| 632 |
|
| 633 |
-
[^
|
| 634 |
an allocation function `void operator new(std::size_t, std::size_t)`
|
| 635 |
-
as a placement allocation function
|
| 636 |
|
| 637 |
-
[^
|
| 638 |
-
through pointers to memory not allocated by `::operator new`. This
|
| 639 |
-
maintains the ability of many C++ implementations to use binary
|
| 640 |
-
libraries and components written in other languages. In particular,
|
| 641 |
-
this applies to C binaries, because indirection through pointers to
|
| 642 |
-
memory allocated by `std::malloc` is not restricted.
|
| 643 |
-
|
| 644 |
-
[^17]: The same rules apply to initialization of an `initializer_list`
|
| 645 |
object [[dcl.init.list]] with its underlying temporary array.
|
| 646 |
|
| 647 |
-
[^
|
| 648 |
`std::memcpy` or `std::memmove`.
|
| 649 |
|
| 650 |
-
[^
|
| 651 |
`std::memcpy` or `std::memmove`.
|
| 652 |
|
| 653 |
-
[^
|
| 654 |
that of ISO/IEC 9899 Programming Language C.
|
| 655 |
|
| 656 |
-
[^
|
| 657 |
object type is unknown.
|
| 658 |
|
| 659 |
-
[^
|
| 660 |
|
| 661 |
-
[^
|
| 662 |
them are ordinary pointers to objects or functions.
|
| 663 |
|
| 664 |
-
[^
|
| 665 |
byte in memory that it will occupy or used to occupy.
|
| 666 |
|
| 667 |
-
[^
|
| 668 |
imply interchangeability as arguments to functions, return values
|
| 669 |
from functions, and non-static data members of unions.
|
| 670 |
|
| 671 |
-
[^
|
| 672 |
evaluated, a sequence of zero or more invocations of destructor
|
| 673 |
functions for temporary objects takes place, usually in reverse
|
| 674 |
order of the construction of each temporary object.
|
| 675 |
|
| 676 |
-
[^
|
| 677 |
other.
|
| 678 |
|
| 679 |
-
[^
|
| 680 |
is associated with one specific thread, and can be accessed by a
|
| 681 |
different thread only indirectly through a pointer or reference
|
| 682 |
[[basic.compound]].
|
| 683 |
|
| 684 |
-
[^
|
| 685 |
initialization with side effects is initialized in this case, even
|
| 686 |
-
if it is not itself odr-used
|
| 687 |
-
[[basic.stc.static]]).
|
|
|
|
| 1 |
### Start and termination <a id="basic.start">[[basic.start]]</a>
|
| 2 |
|
| 3 |
#### `main` function <a id="basic.start.main">[[basic.start.main]]</a>
|
| 4 |
|
| 5 |
+
A program shall contain exactly one function called `main` that belongs
|
| 6 |
+
to the global scope. Executing a program starts a main thread of
|
| 7 |
+
execution [[intro.multithread]], [[thread.threads]] in which the `main`
|
| 8 |
+
function is invoked. It is *implementation-defined* whether a program in
|
| 9 |
+
a freestanding environment is required to define a `main` function.
|
|
|
|
|
|
|
| 10 |
|
| 11 |
[*Note 1*: In a freestanding environment, startup and termination is
|
| 12 |
*implementation-defined*; startup contains the execution of constructors
|
| 13 |
+
for non-local objects with static storage duration; termination contains
|
| 14 |
+
the execution of destructors for objects with static storage
|
| 15 |
duration. — *end note*]
|
| 16 |
|
| 17 |
+
An implementation shall not predefine the `main` function. Its type
|
| 18 |
+
shall have C++ language linkage and it shall have a declared return type
|
| 19 |
+
of type `int`, but otherwise its type is *implementation-defined*. An
|
| 20 |
+
implementation shall allow both
|
| 21 |
|
| 22 |
- a function of `()` returning `int` and
|
| 23 |
- a function of `(int`, pointer to pointer to `char)` returning `int`
|
| 24 |
|
| 25 |
as the type of `main` [[dcl.fct]]. In the latter form, for purposes of
|
|
|
|
| 32 |
[[multibyte.strings]] and `argv[0]` shall be the pointer to the initial
|
| 33 |
character of a NTMBS that represents the name used to invoke the program
|
| 34 |
or `""`. The value of `argc` shall be non-negative. The value of
|
| 35 |
`argv[argc]` shall be 0.
|
| 36 |
|
| 37 |
+
*Recommended practice:* Any further (optional) parameters should be
|
| 38 |
+
added after `argv`.
|
| 39 |
|
| 40 |
The function `main` shall not be used within a program. The linkage
|
| 41 |
[[basic.link]] of `main` is *implementation-defined*. A program that
|
| 42 |
defines `main` as deleted or that declares `main` to be `inline`,
|
| 43 |
+
`static`, `constexpr`, or `consteval` is ill-formed. The function `main`
|
| 44 |
+
shall not be a coroutine [[dcl.fct.def.coroutine]]. The `main` function
|
| 45 |
+
shall not be declared with a *linkage-specification* [[dcl.link]]. A
|
| 46 |
+
program that declares
|
| 47 |
+
|
| 48 |
+
- a variable `main` that belongs to the global scope, or
|
| 49 |
+
- a function `main` that belongs to the global scope and is attached to
|
| 50 |
+
a named module, or
|
| 51 |
+
- a function template `main` that belongs to the global scope, or
|
| 52 |
+
- an entity named `main` with C language linkage (in any namespace)
|
| 53 |
+
|
| 54 |
+
is ill-formed. The name `main` is not otherwise reserved.
|
| 55 |
|
| 56 |
[*Example 1*: Member functions, classes, and enumerations can be called
|
| 57 |
`main`, as can entities in other namespaces. — *end example*]
|
| 58 |
|
| 59 |
Terminating the program without leaving the current block (e.g., by
|
| 60 |
calling the function `std::exit(int)` [[support.start.term]]) does not
|
| 61 |
destroy any objects with automatic storage duration [[class.dtor]]. If
|
| 62 |
+
`std::exit` is invoked during the destruction of an object with static
|
| 63 |
+
or thread storage duration, the program has undefined behavior.
|
|
|
|
| 64 |
|
| 65 |
A `return` statement [[stmt.return]] in `main` has the effect of leaving
|
| 66 |
the main function (destroying any objects with automatic storage
|
| 67 |
duration) and calling `std::exit` with the return value as the argument.
|
| 68 |
If control flows off the end of the *compound-statement* of `main`, the
|
|
|
|
| 80 |
with static or thread storage duration is constant-initialized
|
| 81 |
[[expr.const]]. If constant initialization is not performed, a variable
|
| 82 |
with static storage duration [[basic.stc.static]] or thread storage
|
| 83 |
duration [[basic.stc.thread]] is zero-initialized [[dcl.init]].
|
| 84 |
Together, zero-initialization and constant initialization are called
|
| 85 |
+
*static initialization*; all other initialization is
|
| 86 |
+
*dynamic initialization*. All static initialization strongly happens
|
| 87 |
+
before [[intro.races]] any dynamic initialization.
|
| 88 |
|
| 89 |
+
[*Note 1*: The dynamic initialization of non-block variables is
|
| 90 |
+
described in [[basic.start.dynamic]]; that of static block variables is
|
| 91 |
described in [[stmt.dcl]]. — *end note*]
|
| 92 |
|
| 93 |
An implementation is permitted to perform the initialization of a
|
| 94 |
variable with static or thread storage duration as a static
|
| 95 |
initialization even if such initialization is not required to be done
|
|
|
|
| 104 |
statically were initialized dynamically.
|
| 105 |
|
| 106 |
[*Note 2*:
|
| 107 |
|
| 108 |
As a consequence, if the initialization of an object `obj1` refers to an
|
| 109 |
+
object `obj2` potentially requiring dynamic initialization and defined
|
| 110 |
+
later in the same translation unit, it is unspecified whether the value
|
| 111 |
+
of `obj2` used will be the value of the fully initialized `obj2`
|
| 112 |
+
(because `obj2` was statically initialized) or will be the value of
|
| 113 |
+
`obj2` merely zero-initialized. For example,
|
| 114 |
|
| 115 |
``` cpp
|
| 116 |
inline double fd() { return 1.0; }
|
| 117 |
extern double d1;
|
| 118 |
double d2 = d1; // unspecified:
|
| 119 |
+
// either statically initialized to 0.0 or
|
| 120 |
// dynamically initialized to 0.0 if d1 is
|
| 121 |
// dynamically initialized, or 1.0 otherwise
|
| 122 |
+
double d1 = fd(); // either initialized statically or dynamically to 1.0
|
| 123 |
```
|
| 124 |
|
| 125 |
— *end note*]
|
| 126 |
|
| 127 |
+
#### Dynamic initialization of non-block variables <a id="basic.start.dynamic">[[basic.start.dynamic]]</a>
|
| 128 |
|
| 129 |
+
Dynamic initialization of a non-block variable with static storage
|
| 130 |
duration is unordered if the variable is an implicitly or explicitly
|
| 131 |
instantiated specialization, is partially-ordered if the variable is an
|
| 132 |
inline variable that is not an implicitly or explicitly instantiated
|
| 133 |
specialization, and otherwise is ordered.
|
| 134 |
|
| 135 |
+
[*Note 1*: A non-inline explicit specialization of a templated variable
|
| 136 |
+
has ordered initialization. — *end note*]
|
|
|
|
| 137 |
|
| 138 |
A declaration `D` is *appearance-ordered* before a declaration `E` if
|
| 139 |
|
| 140 |
- `D` appears in the same translation unit as `E`, or
|
| 141 |
- the translation unit containing `E` has an interface dependency on the
|
| 142 |
translation unit containing `D`,
|
| 143 |
|
| 144 |
in either case prior to `E`.
|
| 145 |
|
| 146 |
+
Dynamic initialization of non-block variables `V` and `W` with static
|
| 147 |
storage duration are ordered as follows:
|
| 148 |
|
| 149 |
- If `V` and `W` have ordered initialization and the definition of `V`
|
| 150 |
is appearance-ordered before the definition of `W`, or if `V` has
|
| 151 |
partially-ordered initialization, `W` does not have unordered
|
|
|
|
| 167 |
sequenced.
|
| 168 |
|
| 169 |
[*Note 2*: This definition permits initialization of a sequence of
|
| 170 |
ordered variables concurrently with another sequence. — *end note*]
|
| 171 |
|
| 172 |
+
A *non-initialization odr-use* is an odr-use [[term.odr.use]] not caused
|
| 173 |
+
directly or indirectly by the initialization of a non-block static or
|
| 174 |
+
thread storage duration variable.
|
| 175 |
|
| 176 |
It is *implementation-defined* whether the dynamic initialization of a
|
| 177 |
+
non-block non-inline variable with static storage duration is sequenced
|
| 178 |
before the first statement of `main` or is deferred. If it is deferred,
|
| 179 |
it strongly happens before any non-initialization odr-use of any
|
| 180 |
non-inline function or non-inline variable defined in the same
|
| 181 |
+
translation unit as the variable to be initialized.[^25]
|
|
|
|
|
|
|
| 182 |
|
| 183 |
+
It is *implementation-defined* in which threads and at which points in
|
| 184 |
+
the program such deferred dynamic initialization occurs.
|
| 185 |
+
|
| 186 |
+
*Recommended practice:* An implementation should choose such points in a
|
| 187 |
+
way that allows the programmer to avoid deadlocks.
|
| 188 |
|
| 189 |
[*Example 1*:
|
| 190 |
|
| 191 |
``` cpp
|
| 192 |
// - File 1 -
|
|
|
|
| 223 |
to its use in `A::A`.
|
| 224 |
|
| 225 |
— *end example*]
|
| 226 |
|
| 227 |
It is *implementation-defined* whether the dynamic initialization of a
|
| 228 |
+
non-block inline variable with static storage duration is sequenced
|
| 229 |
before the first statement of `main` or is deferred. If it is deferred,
|
| 230 |
it strongly happens before any non-initialization odr-use of that
|
| 231 |
variable. It is *implementation-defined* in which threads and at which
|
| 232 |
points in the program such deferred dynamic initialization occurs.
|
| 233 |
|
| 234 |
It is *implementation-defined* whether the dynamic initialization of a
|
| 235 |
+
non-block non-inline variable with thread storage duration is sequenced
|
| 236 |
before the first statement of the initial function of a thread or is
|
| 237 |
deferred. If it is deferred, the initialization associated with the
|
| 238 |
entity for thread *t* is sequenced before the first non-initialization
|
| 239 |
odr-use by *t* of any non-inline variable with thread storage duration
|
| 240 |
defined in the same translation unit as the variable to be initialized.
|
| 241 |
It is *implementation-defined* in which threads and at which points in
|
| 242 |
the program such deferred dynamic initialization occurs.
|
| 243 |
|
| 244 |
+
If the initialization of a non-block variable with static or thread
|
| 245 |
storage duration exits via an exception, the function `std::terminate`
|
| 246 |
is called [[except.terminate]].
|
| 247 |
|
| 248 |
#### Termination <a id="basic.start.term">[[basic.start.term]]</a>
|
| 249 |
|
|
|
|
| 270 |
storage duration is sequenced before that of another, the completion of
|
| 271 |
the destructor of the second is sequenced before the initiation of the
|
| 272 |
destructor of the first. If an object is initialized statically, the
|
| 273 |
object is destroyed in the same order as if the object was dynamically
|
| 274 |
initialized. For an object of array or class type, all subobjects of
|
| 275 |
+
that object are destroyed before any block variable with static storage
|
| 276 |
+
duration initialized during the construction of the subobjects is
|
| 277 |
+
destroyed. If the destruction of an object with static or thread storage
|
| 278 |
+
duration exits via an exception, the function `std::terminate` is called
|
| 279 |
+
[[except.terminate]].
|
| 280 |
|
| 281 |
+
If a function contains a block variable of static or thread storage
|
| 282 |
duration that has been destroyed and the function is called during the
|
| 283 |
destruction of an object with static or thread storage duration, the
|
| 284 |
program has undefined behavior if the flow of control passes through the
|
| 285 |
+
definition of the previously destroyed block variable.
|
| 286 |
+
|
| 287 |
+
[*Note 2*: Likewise, the behavior is undefined if the block variable is
|
| 288 |
+
used indirectly (e.g., through a pointer) after its
|
| 289 |
+
destruction. — *end note*]
|
| 290 |
|
| 291 |
If the completion of the initialization of an object with static storage
|
| 292 |
duration strongly happens before a call to `std::atexit` (see
|
| 293 |
`<cstdlib>`, [[support.start.term]]), the call to the function passed to
|
| 294 |
`std::atexit` is sequenced before the call to the destructor for the
|
|
|
|
| 305 |
within signal handlers [[support.runtime]] that does not happen before
|
| 306 |
[[intro.multithread]] completion of destruction of objects with static
|
| 307 |
storage duration and execution of `std::atexit` registered functions
|
| 308 |
[[support.start.term]], the program has undefined behavior.
|
| 309 |
|
| 310 |
+
[*Note 3*: If there is a use of an object with static storage duration
|
| 311 |
that does not happen before the object’s destruction, the program has
|
| 312 |
undefined behavior. Terminating every thread before a call to
|
| 313 |
`std::exit` or the exit from `main` is sufficient, but not necessary, to
|
| 314 |
satisfy these requirements. These requirements permit thread managers as
|
| 315 |
static-storage-duration objects. — *end note*]
|
|
|
|
| 317 |
Calling the function `std::abort()` declared in `<cstdlib>` terminates
|
| 318 |
the program without executing any destructors and without calling the
|
| 319 |
functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
| 320 |
|
| 321 |
<!-- Link reference definitions -->
|
| 322 |
+
[allocator.members]: mem.md#allocator.members
|
| 323 |
+
[allocator.traits.members]: mem.md#allocator.traits.members
|
| 324 |
+
[atomics]: thread.md#atomics
|
| 325 |
+
[atomics.flag]: thread.md#atomics.flag
|
| 326 |
+
[atomics.lockfree]: thread.md#atomics.lockfree
|
| 327 |
+
[atomics.order]: thread.md#atomics.order
|
| 328 |
[bad.alloc]: support.md#bad.alloc
|
| 329 |
[basic]: #basic
|
| 330 |
[basic.align]: #basic.align
|
| 331 |
[basic.compound]: #basic.compound
|
| 332 |
[basic.def]: #basic.def
|
| 333 |
[basic.def.odr]: #basic.def.odr
|
| 334 |
[basic.exec]: #basic.exec
|
| 335 |
+
[basic.extended.fp]: #basic.extended.fp
|
| 336 |
[basic.fundamental]: #basic.fundamental
|
| 337 |
[basic.fundamental.width]: #basic.fundamental.width
|
|
|
|
| 338 |
[basic.indet]: #basic.indet
|
| 339 |
[basic.life]: #basic.life
|
| 340 |
[basic.link]: #basic.link
|
| 341 |
[basic.lookup]: #basic.lookup
|
| 342 |
[basic.lookup.argdep]: #basic.lookup.argdep
|
|
|
|
| 343 |
[basic.lookup.elab]: #basic.lookup.elab
|
| 344 |
+
[basic.lookup.general]: #basic.lookup.general
|
| 345 |
[basic.lookup.qual]: #basic.lookup.qual
|
| 346 |
+
[basic.lookup.qual.general]: #basic.lookup.qual.general
|
| 347 |
[basic.lookup.udir]: #basic.lookup.udir
|
| 348 |
[basic.lookup.unqual]: #basic.lookup.unqual
|
| 349 |
[basic.lval]: expr.md#basic.lval
|
| 350 |
[basic.memobj]: #basic.memobj
|
| 351 |
[basic.namespace]: dcl.md#basic.namespace
|
| 352 |
[basic.pre]: #basic.pre
|
| 353 |
[basic.scope]: #basic.scope
|
| 354 |
[basic.scope.block]: #basic.scope.block
|
| 355 |
[basic.scope.class]: #basic.scope.class
|
|
|
|
| 356 |
[basic.scope.enum]: #basic.scope.enum
|
| 357 |
+
[basic.scope.lambda]: #basic.scope.lambda
|
| 358 |
[basic.scope.namespace]: #basic.scope.namespace
|
| 359 |
[basic.scope.param]: #basic.scope.param
|
| 360 |
[basic.scope.pdecl]: #basic.scope.pdecl
|
| 361 |
+
[basic.scope.scope]: #basic.scope.scope
|
| 362 |
[basic.scope.temp]: #basic.scope.temp
|
| 363 |
[basic.start]: #basic.start
|
| 364 |
[basic.start.dynamic]: #basic.start.dynamic
|
| 365 |
[basic.start.main]: #basic.start.main
|
| 366 |
[basic.start.static]: #basic.start.static
|
|
|
|
| 368 |
[basic.stc]: #basic.stc
|
| 369 |
[basic.stc.auto]: #basic.stc.auto
|
| 370 |
[basic.stc.dynamic]: #basic.stc.dynamic
|
| 371 |
[basic.stc.dynamic.allocation]: #basic.stc.dynamic.allocation
|
| 372 |
[basic.stc.dynamic.deallocation]: #basic.stc.dynamic.deallocation
|
| 373 |
+
[basic.stc.dynamic.general]: #basic.stc.dynamic.general
|
| 374 |
+
[basic.stc.general]: #basic.stc.general
|
| 375 |
[basic.stc.inherit]: #basic.stc.inherit
|
| 376 |
[basic.stc.static]: #basic.stc.static
|
| 377 |
[basic.stc.thread]: #basic.stc.thread
|
| 378 |
[basic.type.qualifier]: #basic.type.qualifier
|
| 379 |
[basic.type.qualifier.rel]: #basic.type.qualifier.rel
|
| 380 |
[basic.types]: #basic.types
|
| 381 |
+
[basic.types.general]: #basic.types.general
|
| 382 |
+
[bit.cast]: utilities.md#bit.cast
|
| 383 |
+
[c.malloc]: mem.md#c.malloc
|
| 384 |
[class]: class.md#class
|
| 385 |
[class.abstract]: class.md#class.abstract
|
| 386 |
[class.access]: class.md#class.access
|
| 387 |
+
[class.access.base]: class.md#class.access.base
|
| 388 |
[class.base.init]: class.md#class.base.init
|
| 389 |
[class.bit]: class.md#class.bit
|
| 390 |
[class.cdtor]: class.md#class.cdtor
|
| 391 |
[class.conv.fct]: class.md#class.conv.fct
|
| 392 |
[class.copy.assign]: class.md#class.copy.assign
|
|
|
|
| 395 |
[class.default.ctor]: class.md#class.default.ctor
|
| 396 |
[class.derived]: class.md#class.derived
|
| 397 |
[class.dtor]: class.md#class.dtor
|
| 398 |
[class.free]: class.md#class.free
|
| 399 |
[class.friend]: class.md#class.friend
|
|
|
|
| 400 |
[class.mem]: class.md#class.mem
|
| 401 |
+
[class.member.lookup]: #class.member.lookup
|
| 402 |
[class.mfct]: class.md#class.mfct
|
| 403 |
+
[class.mfct.non.static]: class.md#class.mfct.non.static
|
| 404 |
[class.name]: class.md#class.name
|
|
|
|
| 405 |
[class.pre]: class.md#class.pre
|
| 406 |
[class.prop]: class.md#class.prop
|
| 407 |
[class.qual]: #class.qual
|
| 408 |
[class.spaceship]: class.md#class.spaceship
|
| 409 |
[class.static]: class.md#class.static
|
| 410 |
[class.static.data]: class.md#class.static.data
|
| 411 |
[class.temporary]: #class.temporary
|
|
|
|
| 412 |
[class.union]: class.md#class.union
|
| 413 |
+
[class.union.anon]: class.md#class.union.anon
|
| 414 |
[class.virtual]: class.md#class.virtual
|
| 415 |
[conv]: expr.md#conv
|
| 416 |
[conv.array]: expr.md#conv.array
|
| 417 |
[conv.func]: expr.md#conv.func
|
| 418 |
[conv.integral]: expr.md#conv.integral
|
|
|
|
| 440 |
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 441 |
[dcl.init]: dcl.md#dcl.init
|
| 442 |
[dcl.init.aggr]: dcl.md#dcl.init.aggr
|
| 443 |
[dcl.init.list]: dcl.md#dcl.init.list
|
| 444 |
[dcl.init.ref]: dcl.md#dcl.init.ref
|
|
|
|
| 445 |
[dcl.link]: dcl.md#dcl.link
|
| 446 |
[dcl.meaning]: dcl.md#dcl.meaning
|
| 447 |
[dcl.mptr]: dcl.md#dcl.mptr
|
| 448 |
[dcl.name]: dcl.md#dcl.name
|
| 449 |
[dcl.pre]: dcl.md#dcl.pre
|
|
|
|
| 451 |
[dcl.ref]: dcl.md#dcl.ref
|
| 452 |
[dcl.spec]: dcl.md#dcl.spec
|
| 453 |
[dcl.spec.auto]: dcl.md#dcl.spec.auto
|
| 454 |
[dcl.stc]: dcl.md#dcl.stc
|
| 455 |
[dcl.struct.bind]: dcl.md#dcl.struct.bind
|
| 456 |
+
[dcl.type.decltype]: dcl.md#dcl.type.decltype
|
| 457 |
[dcl.type.elab]: dcl.md#dcl.type.elab
|
| 458 |
[dcl.typedef]: dcl.md#dcl.typedef
|
| 459 |
[defns.block]: intro.md#defns.block
|
|
|
|
|
|
|
| 460 |
[depr.local]: future.md#depr.local
|
| 461 |
[depr.static.constexpr]: future.md#depr.static.constexpr
|
| 462 |
[diff.cpp11.basic]: compatibility.md#diff.cpp11.basic
|
| 463 |
[enum.udecl]: dcl.md#enum.udecl
|
| 464 |
[except.handle]: except.md#except.handle
|
| 465 |
[except.pre]: except.md#except.pre
|
| 466 |
[except.spec]: except.md#except.spec
|
| 467 |
[except.terminate]: except.md#except.terminate
|
| 468 |
[except.throw]: except.md#except.throw
|
|
|
|
| 469 |
[expr.add]: expr.md#expr.add
|
| 470 |
[expr.alignof]: expr.md#expr.alignof
|
| 471 |
[expr.arith.conv]: expr.md#expr.arith.conv
|
| 472 |
[expr.ass]: expr.md#expr.ass
|
| 473 |
[expr.await]: expr.md#expr.await
|
| 474 |
[expr.call]: expr.md#expr.call
|
| 475 |
[expr.cast]: expr.md#expr.cast
|
| 476 |
[expr.comma]: expr.md#expr.comma
|
|
|
|
| 477 |
[expr.cond]: expr.md#expr.cond
|
| 478 |
[expr.const]: expr.md#expr.const
|
| 479 |
[expr.const.cast]: expr.md#expr.const.cast
|
| 480 |
[expr.context]: expr.md#expr.context
|
| 481 |
[expr.delete]: expr.md#expr.delete
|
|
|
|
| 485 |
[expr.log.or]: expr.md#expr.log.or
|
| 486 |
[expr.mptr.oper]: expr.md#expr.mptr.oper
|
| 487 |
[expr.new]: expr.md#expr.new
|
| 488 |
[expr.pre]: expr.md#expr.pre
|
| 489 |
[expr.prim.id]: expr.md#expr.prim.id
|
|
|
|
| 490 |
[expr.prim.id.qual]: expr.md#expr.prim.id.qual
|
| 491 |
+
[expr.prim.id.unqual]: expr.md#expr.prim.id.unqual
|
| 492 |
[expr.prim.lambda]: expr.md#expr.prim.lambda
|
| 493 |
[expr.prim.lambda.capture]: expr.md#expr.prim.lambda.capture
|
| 494 |
[expr.prim.lambda.closure]: expr.md#expr.prim.lambda.closure
|
| 495 |
[expr.prim.this]: expr.md#expr.prim.this
|
| 496 |
[expr.prop]: expr.md#expr.prop
|
|
|
|
| 506 |
[get.new.handler]: support.md#get.new.handler
|
| 507 |
[headers]: library.md#headers
|
| 508 |
[intro.execution]: #intro.execution
|
| 509 |
[intro.memory]: #intro.memory
|
| 510 |
[intro.multithread]: #intro.multithread
|
| 511 |
+
[intro.multithread.general]: #intro.multithread.general
|
| 512 |
[intro.object]: #intro.object
|
| 513 |
[intro.progress]: #intro.progress
|
| 514 |
[intro.races]: #intro.races
|
| 515 |
[lex.charset]: lex.md#lex.charset
|
| 516 |
+
[lex.fcon]: lex.md#lex.fcon
|
| 517 |
[lex.name]: lex.md#lex.name
|
| 518 |
[lex.separate]: lex.md#lex.separate
|
|
|
|
|
|
|
| 519 |
[module.context]: module.md#module.context
|
| 520 |
[module.global.frag]: module.md#module.global.frag
|
|
|
|
| 521 |
[module.interface]: module.md#module.interface
|
| 522 |
[module.reach]: module.md#module.reach
|
| 523 |
[module.unit]: module.md#module.unit
|
| 524 |
[multibyte.strings]: library.md#multibyte.strings
|
| 525 |
[namespace.def]: dcl.md#namespace.def
|
|
|
|
| 526 |
[namespace.qual]: #namespace.qual
|
| 527 |
[namespace.udecl]: dcl.md#namespace.udecl
|
| 528 |
[namespace.udir]: dcl.md#namespace.udir
|
| 529 |
+
[namespace.unnamed]: dcl.md#namespace.unnamed
|
| 530 |
[new.delete]: support.md#new.delete
|
| 531 |
[new.delete.array]: support.md#new.delete.array
|
| 532 |
[new.delete.placement]: support.md#new.delete.placement
|
| 533 |
[new.delete.single]: support.md#new.delete.single
|
| 534 |
[new.handler]: support.md#new.handler
|
| 535 |
+
[new.syn]: support.md#new.syn
|
| 536 |
+
[obj.lifetime]: mem.md#obj.lifetime
|
| 537 |
[over]: over.md#over
|
| 538 |
[over.literal]: over.md#over.literal
|
| 539 |
[over.match]: over.md#over.match
|
| 540 |
+
[over.match.funcs]: over.md#over.match.funcs
|
| 541 |
[over.oper]: over.md#over.oper
|
| 542 |
[over.over]: over.md#over.over
|
| 543 |
+
[ptr.align]: mem.md#ptr.align
|
| 544 |
[ptr.launder]: support.md#ptr.launder
|
| 545 |
[replacement.functions]: library.md#replacement.functions
|
| 546 |
[special]: class.md#special
|
| 547 |
+
[std.modules]: library.md#std.modules
|
| 548 |
+
[stdfloat.syn]: support.md#stdfloat.syn
|
| 549 |
[stmt.block]: stmt.md#stmt.block
|
| 550 |
[stmt.dcl]: stmt.md#stmt.dcl
|
| 551 |
[stmt.expr]: stmt.md#stmt.expr
|
|
|
|
| 552 |
[stmt.if]: stmt.md#stmt.if
|
| 553 |
+
[stmt.iter]: stmt.md#stmt.iter
|
| 554 |
+
[stmt.pre]: stmt.md#stmt.pre
|
| 555 |
[stmt.ranged]: stmt.md#stmt.ranged
|
| 556 |
[stmt.return]: stmt.md#stmt.return
|
| 557 |
+
[stmt.select]: stmt.md#stmt.select
|
| 558 |
[support.dynamic]: support.md#support.dynamic
|
|
|
|
| 559 |
[support.runtime]: support.md#support.runtime
|
| 560 |
[support.start.term]: support.md#support.start.term
|
| 561 |
[support.types]: support.md#support.types
|
| 562 |
+
[temp.concept]: temp.md#temp.concept
|
| 563 |
[temp.deduct.guide]: temp.md#temp.deduct.guide
|
| 564 |
[temp.dep]: temp.md#temp.dep
|
| 565 |
[temp.dep.candidate]: temp.md#temp.dep.candidate
|
| 566 |
+
[temp.dep.constexpr]: temp.md#temp.dep.constexpr
|
| 567 |
+
[temp.dep.type]: temp.md#temp.dep.type
|
| 568 |
[temp.expl.spec]: temp.md#temp.expl.spec
|
| 569 |
[temp.explicit]: temp.md#temp.explicit
|
| 570 |
+
[temp.friend]: temp.md#temp.friend
|
| 571 |
[temp.local]: temp.md#temp.local
|
| 572 |
[temp.names]: temp.md#temp.names
|
|
|
|
| 573 |
[temp.over]: temp.md#temp.over
|
| 574 |
+
[temp.over.link]: temp.md#temp.over.link
|
| 575 |
[temp.param]: temp.md#temp.param
|
| 576 |
[temp.point]: temp.md#temp.point
|
| 577 |
[temp.pre]: temp.md#temp.pre
|
| 578 |
[temp.res]: temp.md#temp.res
|
| 579 |
[temp.spec]: temp.md#temp.spec
|
| 580 |
+
[temp.spec.partial]: temp.md#temp.spec.partial
|
| 581 |
[temp.type]: temp.md#temp.type
|
| 582 |
+
[term.incomplete.type]: #term.incomplete.type
|
| 583 |
+
[term.odr.use]: #term.odr.use
|
| 584 |
+
[term.unevaluated.operand]: expr.md#term.unevaluated.operand
|
| 585 |
[thread]: thread.md#thread
|
| 586 |
[thread.jthread.class]: thread.md#thread.jthread.class
|
| 587 |
[thread.thread.class]: thread.md#thread.thread.class
|
| 588 |
[thread.threads]: thread.md#thread.threads
|
|
|
|
| 589 |
|
| 590 |
[^1]: Appearing inside the brace-enclosed *declaration-seq* in a
|
| 591 |
*linkage-specification* does not affect whether a declaration is a
|
| 592 |
definition.
|
| 593 |
|
| 594 |
[^2]: An implementation is not required to call allocation and
|
| 595 |
deallocation functions from constructors or destructors; however,
|
| 596 |
this is a permissible implementation technique.
|
| 597 |
|
| 598 |
+
[^3]: An implicit object parameter [[over.match.funcs]] is not part of
|
| 599 |
+
the parameter-type-list.
|
|
|
|
| 600 |
|
| 601 |
+
[^4]: Lookups in which function names are ignored include names
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 602 |
appearing in a *nested-name-specifier*, an
|
| 603 |
*elaborated-type-specifier*, or a *base-specifier*.
|
| 604 |
|
| 605 |
+
[^5]: Unicode® is a registered trademark of Unicode, Inc. This
|
| 606 |
+
information is given for the convenience of users of this document
|
| 607 |
+
and does not constitute an endorsement by ISO or IEC of this
|
| 608 |
+
product.
|
| 609 |
+
|
| 610 |
+
[^6]: The number of bits in a byte is reported by the macro `CHAR_BIT`
|
| 611 |
in the header `<climits>`.
|
| 612 |
|
| 613 |
+
[^7]: Under the “as-if” rule an implementation is allowed to store two
|
| 614 |
objects at the same machine address or not store an object at all if
|
| 615 |
the program cannot observe the difference [[intro.execution]].
|
| 616 |
|
| 617 |
+
[^8]: For example, before the dynamic initialization of an object with
|
| 618 |
+
static storage duration [[basic.start.dynamic]].
|
| 619 |
|
| 620 |
+
[^9]: That is, an object for which a destructor will be called
|
| 621 |
implicitly—upon exit from the block for an object with automatic
|
| 622 |
storage duration, upon exit from the thread for an object with
|
| 623 |
thread storage duration, or upon exit from the program for an object
|
| 624 |
with static storage duration.
|
| 625 |
|
| 626 |
+
[^10]: Some implementations might define that copying an invalid pointer
|
| 627 |
value causes a system-generated runtime fault.
|
| 628 |
|
| 629 |
+
[^11]: The intent is to have `operator new()` implementable by calling
|
| 630 |
`std::malloc()` or `std::calloc()`, so the rules are substantially
|
| 631 |
the same. C++ differs from C in requiring a zero request to return a
|
| 632 |
non-null pointer.
|
| 633 |
|
| 634 |
+
[^12]: The global `operator delete(void*, std::size_t)` precludes use of
|
| 635 |
an allocation function `void operator new(std::size_t, std::size_t)`
|
| 636 |
+
as a placement allocation function [[diff.cpp11.basic]].
|
| 637 |
|
| 638 |
+
[^13]: The same rules apply to initialization of an `initializer_list`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 639 |
object [[dcl.init.list]] with its underlying temporary array.
|
| 640 |
|
| 641 |
+
[^14]: By using, for example, the library functions [[headers]]
|
| 642 |
`std::memcpy` or `std::memmove`.
|
| 643 |
|
| 644 |
+
[^15]: By using, for example, the library functions [[headers]]
|
| 645 |
`std::memcpy` or `std::memmove`.
|
| 646 |
|
| 647 |
+
[^16]: The intent is that the memory model of C++ is compatible with
|
| 648 |
that of ISO/IEC 9899 Programming Language C.
|
| 649 |
|
| 650 |
+
[^17]: The size and layout of an instance of an incompletely-defined
|
| 651 |
object type is unknown.
|
| 652 |
|
| 653 |
+
[^18]: This is also known as two’s complement representation.
|
| 654 |
|
| 655 |
+
[^19]: Static class members are objects or functions, and pointers to
|
| 656 |
them are ordinary pointers to objects or functions.
|
| 657 |
|
| 658 |
+
[^20]: For an object that is not within its lifetime, this is the first
|
| 659 |
byte in memory that it will occupy or used to occupy.
|
| 660 |
|
| 661 |
+
[^21]: The same representation and alignment requirements are meant to
|
| 662 |
imply interchangeability as arguments to functions, return values
|
| 663 |
from functions, and non-static data members of unions.
|
| 664 |
|
| 665 |
+
[^22]: As specified in [[class.temporary]], after a full-expression is
|
| 666 |
evaluated, a sequence of zero or more invocations of destructor
|
| 667 |
functions for temporary objects takes place, usually in reverse
|
| 668 |
order of the construction of each temporary object.
|
| 669 |
|
| 670 |
+
[^23]: In other words, function executions do not interleave with each
|
| 671 |
other.
|
| 672 |
|
| 673 |
+
[^24]: An object with automatic or thread storage duration [[basic.stc]]
|
| 674 |
is associated with one specific thread, and can be accessed by a
|
| 675 |
different thread only indirectly through a pointer or reference
|
| 676 |
[[basic.compound]].
|
| 677 |
|
| 678 |
+
[^25]: A non-block variable with static storage duration having
|
| 679 |
initialization with side effects is initialized in this case, even
|
| 680 |
+
if it is not itself odr-used [[term.odr.use]], [[basic.stc.static]].
|
|
|