tmp/tmpt9gz5ozq/{from.md → to.md}
RENAMED
|
@@ -23,23 +23,25 @@ of the constructor or dynamic initialization of an object with thread
|
|
| 23 |
storage duration is sequenced before that of another, the completion of
|
| 24 |
the destructor of the second is sequenced before the initiation of the
|
| 25 |
destructor of the first. If an object is initialized statically, the
|
| 26 |
object is destroyed in the same order as if the object was dynamically
|
| 27 |
initialized. For an object of array or class type, all subobjects of
|
| 28 |
-
that object are destroyed before any block
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
-
If a function contains a block
|
| 35 |
duration that has been destroyed and the function is called during the
|
| 36 |
destruction of an object with static or thread storage duration, the
|
| 37 |
program has undefined behavior if the flow of control passes through the
|
| 38 |
-
definition of the previously destroyed block
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
|
| 42 |
If the completion of the initialization of an object with static storage
|
| 43 |
duration strongly happens before a call to `std::atexit` (see
|
| 44 |
`<cstdlib>`, [[support.start.term]]), the call to the function passed to
|
| 45 |
`std::atexit` is sequenced before the call to the destructor for the
|
|
@@ -56,11 +58,11 @@ If there is a use of a standard library object or function not permitted
|
|
| 56 |
within signal handlers [[support.runtime]] that does not happen before
|
| 57 |
[[intro.multithread]] completion of destruction of objects with static
|
| 58 |
storage duration and execution of `std::atexit` registered functions
|
| 59 |
[[support.start.term]], the program has undefined behavior.
|
| 60 |
|
| 61 |
-
[*Note
|
| 62 |
that does not happen before the object’s destruction, the program has
|
| 63 |
undefined behavior. Terminating every thread before a call to
|
| 64 |
`std::exit` or the exit from `main` is sufficient, but not necessary, to
|
| 65 |
satisfy these requirements. These requirements permit thread managers as
|
| 66 |
static-storage-duration objects. — *end note*]
|
|
@@ -68,49 +70,50 @@ static-storage-duration objects. — *end note*]
|
|
| 68 |
Calling the function `std::abort()` declared in `<cstdlib>` terminates
|
| 69 |
the program without executing any destructors and without calling the
|
| 70 |
functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
| 71 |
|
| 72 |
<!-- Link reference definitions -->
|
| 73 |
-
[allocator.members]:
|
| 74 |
-
[allocator.traits.members]:
|
| 75 |
-
[atomics]:
|
| 76 |
-
[atomics.flag]:
|
| 77 |
-
[atomics.lockfree]:
|
| 78 |
-
[atomics.order]:
|
| 79 |
[bad.alloc]: support.md#bad.alloc
|
| 80 |
[basic]: #basic
|
| 81 |
[basic.align]: #basic.align
|
| 82 |
[basic.compound]: #basic.compound
|
| 83 |
[basic.def]: #basic.def
|
| 84 |
[basic.def.odr]: #basic.def.odr
|
| 85 |
[basic.exec]: #basic.exec
|
|
|
|
| 86 |
[basic.fundamental]: #basic.fundamental
|
| 87 |
[basic.fundamental.width]: #basic.fundamental.width
|
| 88 |
-
[basic.funscope]: #basic.funscope
|
| 89 |
[basic.indet]: #basic.indet
|
| 90 |
[basic.life]: #basic.life
|
| 91 |
[basic.link]: #basic.link
|
| 92 |
[basic.lookup]: #basic.lookup
|
| 93 |
[basic.lookup.argdep]: #basic.lookup.argdep
|
| 94 |
-
[basic.lookup.classref]: #basic.lookup.classref
|
| 95 |
[basic.lookup.elab]: #basic.lookup.elab
|
|
|
|
| 96 |
[basic.lookup.qual]: #basic.lookup.qual
|
|
|
|
| 97 |
[basic.lookup.udir]: #basic.lookup.udir
|
| 98 |
[basic.lookup.unqual]: #basic.lookup.unqual
|
| 99 |
[basic.lval]: expr.md#basic.lval
|
| 100 |
[basic.memobj]: #basic.memobj
|
| 101 |
[basic.namespace]: dcl.md#basic.namespace
|
| 102 |
[basic.pre]: #basic.pre
|
| 103 |
[basic.scope]: #basic.scope
|
| 104 |
[basic.scope.block]: #basic.scope.block
|
| 105 |
[basic.scope.class]: #basic.scope.class
|
| 106 |
-
[basic.scope.declarative]: #basic.scope.declarative
|
| 107 |
[basic.scope.enum]: #basic.scope.enum
|
| 108 |
-
[basic.scope.
|
| 109 |
[basic.scope.namespace]: #basic.scope.namespace
|
| 110 |
[basic.scope.param]: #basic.scope.param
|
| 111 |
[basic.scope.pdecl]: #basic.scope.pdecl
|
|
|
|
| 112 |
[basic.scope.temp]: #basic.scope.temp
|
| 113 |
[basic.start]: #basic.start
|
| 114 |
[basic.start.dynamic]: #basic.start.dynamic
|
| 115 |
[basic.start.main]: #basic.start.main
|
| 116 |
[basic.start.static]: #basic.start.static
|
|
@@ -118,22 +121,25 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 118 |
[basic.stc]: #basic.stc
|
| 119 |
[basic.stc.auto]: #basic.stc.auto
|
| 120 |
[basic.stc.dynamic]: #basic.stc.dynamic
|
| 121 |
[basic.stc.dynamic.allocation]: #basic.stc.dynamic.allocation
|
| 122 |
[basic.stc.dynamic.deallocation]: #basic.stc.dynamic.deallocation
|
| 123 |
-
[basic.stc.dynamic.
|
|
|
|
| 124 |
[basic.stc.inherit]: #basic.stc.inherit
|
| 125 |
[basic.stc.static]: #basic.stc.static
|
| 126 |
[basic.stc.thread]: #basic.stc.thread
|
| 127 |
[basic.type.qualifier]: #basic.type.qualifier
|
| 128 |
[basic.type.qualifier.rel]: #basic.type.qualifier.rel
|
| 129 |
[basic.types]: #basic.types
|
| 130 |
-
[
|
| 131 |
-
[
|
|
|
|
| 132 |
[class]: class.md#class
|
| 133 |
[class.abstract]: class.md#class.abstract
|
| 134 |
[class.access]: class.md#class.access
|
|
|
|
| 135 |
[class.base.init]: class.md#class.base.init
|
| 136 |
[class.bit]: class.md#class.bit
|
| 137 |
[class.cdtor]: class.md#class.cdtor
|
| 138 |
[class.conv.fct]: class.md#class.conv.fct
|
| 139 |
[class.copy.assign]: class.md#class.copy.assign
|
|
@@ -142,26 +148,24 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 142 |
[class.default.ctor]: class.md#class.default.ctor
|
| 143 |
[class.derived]: class.md#class.derived
|
| 144 |
[class.dtor]: class.md#class.dtor
|
| 145 |
[class.free]: class.md#class.free
|
| 146 |
[class.friend]: class.md#class.friend
|
| 147 |
-
[class.local]: class.md#class.local
|
| 148 |
[class.mem]: class.md#class.mem
|
| 149 |
-
[class.member.lookup]:
|
| 150 |
[class.mfct]: class.md#class.mfct
|
| 151 |
-
[class.mfct.non
|
| 152 |
[class.name]: class.md#class.name
|
| 153 |
-
[class.nest]: class.md#class.nest
|
| 154 |
[class.pre]: class.md#class.pre
|
| 155 |
[class.prop]: class.md#class.prop
|
| 156 |
[class.qual]: #class.qual
|
| 157 |
[class.spaceship]: class.md#class.spaceship
|
| 158 |
[class.static]: class.md#class.static
|
| 159 |
[class.static.data]: class.md#class.static.data
|
| 160 |
[class.temporary]: #class.temporary
|
| 161 |
-
[class.this]: class.md#class.this
|
| 162 |
[class.union]: class.md#class.union
|
|
|
|
| 163 |
[class.virtual]: class.md#class.virtual
|
| 164 |
[conv]: expr.md#conv
|
| 165 |
[conv.array]: expr.md#conv.array
|
| 166 |
[conv.func]: expr.md#conv.func
|
| 167 |
[conv.integral]: expr.md#conv.integral
|
|
@@ -189,11 +193,10 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 189 |
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 190 |
[dcl.init]: dcl.md#dcl.init
|
| 191 |
[dcl.init.aggr]: dcl.md#dcl.init.aggr
|
| 192 |
[dcl.init.list]: dcl.md#dcl.init.list
|
| 193 |
[dcl.init.ref]: dcl.md#dcl.init.ref
|
| 194 |
-
[dcl.inline]: dcl.md#dcl.inline
|
| 195 |
[dcl.link]: dcl.md#dcl.link
|
| 196 |
[dcl.meaning]: dcl.md#dcl.meaning
|
| 197 |
[dcl.mptr]: dcl.md#dcl.mptr
|
| 198 |
[dcl.name]: dcl.md#dcl.name
|
| 199 |
[dcl.pre]: dcl.md#dcl.pre
|
|
@@ -201,34 +204,31 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 201 |
[dcl.ref]: dcl.md#dcl.ref
|
| 202 |
[dcl.spec]: dcl.md#dcl.spec
|
| 203 |
[dcl.spec.auto]: dcl.md#dcl.spec.auto
|
| 204 |
[dcl.stc]: dcl.md#dcl.stc
|
| 205 |
[dcl.struct.bind]: dcl.md#dcl.struct.bind
|
|
|
|
| 206 |
[dcl.type.elab]: dcl.md#dcl.type.elab
|
| 207 |
[dcl.typedef]: dcl.md#dcl.typedef
|
| 208 |
[defns.block]: intro.md#defns.block
|
| 209 |
-
[defns.signature]: intro.md#defns.signature
|
| 210 |
-
[defns.signature.templ]: intro.md#defns.signature.templ
|
| 211 |
[depr.local]: future.md#depr.local
|
| 212 |
[depr.static.constexpr]: future.md#depr.static.constexpr
|
| 213 |
[diff.cpp11.basic]: compatibility.md#diff.cpp11.basic
|
| 214 |
[enum.udecl]: dcl.md#enum.udecl
|
| 215 |
[except.handle]: except.md#except.handle
|
| 216 |
[except.pre]: except.md#except.pre
|
| 217 |
[except.spec]: except.md#except.spec
|
| 218 |
[except.terminate]: except.md#except.terminate
|
| 219 |
[except.throw]: except.md#except.throw
|
| 220 |
-
[expr]: expr.md#expr
|
| 221 |
[expr.add]: expr.md#expr.add
|
| 222 |
[expr.alignof]: expr.md#expr.alignof
|
| 223 |
[expr.arith.conv]: expr.md#expr.arith.conv
|
| 224 |
[expr.ass]: expr.md#expr.ass
|
| 225 |
[expr.await]: expr.md#expr.await
|
| 226 |
[expr.call]: expr.md#expr.call
|
| 227 |
[expr.cast]: expr.md#expr.cast
|
| 228 |
[expr.comma]: expr.md#expr.comma
|
| 229 |
-
[expr.compound]: expr.md#expr.compound
|
| 230 |
[expr.cond]: expr.md#expr.cond
|
| 231 |
[expr.const]: expr.md#expr.const
|
| 232 |
[expr.const.cast]: expr.md#expr.const.cast
|
| 233 |
[expr.context]: expr.md#expr.context
|
| 234 |
[expr.delete]: expr.md#expr.delete
|
|
@@ -238,12 +238,12 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 238 |
[expr.log.or]: expr.md#expr.log.or
|
| 239 |
[expr.mptr.oper]: expr.md#expr.mptr.oper
|
| 240 |
[expr.new]: expr.md#expr.new
|
| 241 |
[expr.pre]: expr.md#expr.pre
|
| 242 |
[expr.prim.id]: expr.md#expr.prim.id
|
| 243 |
-
[expr.prim.id.dtor]: expr.md#expr.prim.id.dtor
|
| 244 |
[expr.prim.id.qual]: expr.md#expr.prim.id.qual
|
|
|
|
| 245 |
[expr.prim.lambda]: expr.md#expr.prim.lambda
|
| 246 |
[expr.prim.lambda.capture]: expr.md#expr.prim.lambda.capture
|
| 247 |
[expr.prim.lambda.closure]: expr.md#expr.prim.lambda.closure
|
| 248 |
[expr.prim.this]: expr.md#expr.prim.this
|
| 249 |
[expr.prop]: expr.md#expr.prop
|
|
@@ -259,184 +259,175 @@ functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
|
| 259 |
[get.new.handler]: support.md#get.new.handler
|
| 260 |
[headers]: library.md#headers
|
| 261 |
[intro.execution]: #intro.execution
|
| 262 |
[intro.memory]: #intro.memory
|
| 263 |
[intro.multithread]: #intro.multithread
|
|
|
|
| 264 |
[intro.object]: #intro.object
|
| 265 |
[intro.progress]: #intro.progress
|
| 266 |
[intro.races]: #intro.races
|
| 267 |
[lex.charset]: lex.md#lex.charset
|
|
|
|
| 268 |
[lex.name]: lex.md#lex.name
|
| 269 |
[lex.separate]: lex.md#lex.separate
|
| 270 |
-
[locale]: localization.md#locale
|
| 271 |
-
[meta.trans.other]: utilities.md#meta.trans.other
|
| 272 |
[module.context]: module.md#module.context
|
| 273 |
[module.global.frag]: module.md#module.global.frag
|
| 274 |
-
[module.import]: module.md#module.import
|
| 275 |
[module.interface]: module.md#module.interface
|
| 276 |
[module.reach]: module.md#module.reach
|
| 277 |
[module.unit]: module.md#module.unit
|
| 278 |
[multibyte.strings]: library.md#multibyte.strings
|
| 279 |
[namespace.def]: dcl.md#namespace.def
|
| 280 |
-
[namespace.memdef]: dcl.md#namespace.memdef
|
| 281 |
[namespace.qual]: #namespace.qual
|
| 282 |
[namespace.udecl]: dcl.md#namespace.udecl
|
| 283 |
[namespace.udir]: dcl.md#namespace.udir
|
|
|
|
| 284 |
[new.delete]: support.md#new.delete
|
| 285 |
[new.delete.array]: support.md#new.delete.array
|
| 286 |
[new.delete.placement]: support.md#new.delete.placement
|
| 287 |
[new.delete.single]: support.md#new.delete.single
|
| 288 |
[new.handler]: support.md#new.handler
|
|
|
|
|
|
|
| 289 |
[over]: over.md#over
|
| 290 |
[over.literal]: over.md#over.literal
|
| 291 |
[over.match]: over.md#over.match
|
|
|
|
| 292 |
[over.oper]: over.md#over.oper
|
| 293 |
[over.over]: over.md#over.over
|
| 294 |
-
[ptr.align]:
|
| 295 |
[ptr.launder]: support.md#ptr.launder
|
| 296 |
[replacement.functions]: library.md#replacement.functions
|
| 297 |
[special]: class.md#special
|
|
|
|
|
|
|
| 298 |
[stmt.block]: stmt.md#stmt.block
|
| 299 |
[stmt.dcl]: stmt.md#stmt.dcl
|
| 300 |
[stmt.expr]: stmt.md#stmt.expr
|
| 301 |
-
[stmt.goto]: stmt.md#stmt.goto
|
| 302 |
[stmt.if]: stmt.md#stmt.if
|
| 303 |
-
[stmt.
|
|
|
|
| 304 |
[stmt.ranged]: stmt.md#stmt.ranged
|
| 305 |
[stmt.return]: stmt.md#stmt.return
|
|
|
|
| 306 |
[support.dynamic]: support.md#support.dynamic
|
| 307 |
-
[support.limits]: support.md#support.limits
|
| 308 |
[support.runtime]: support.md#support.runtime
|
| 309 |
[support.start.term]: support.md#support.start.term
|
| 310 |
[support.types]: support.md#support.types
|
|
|
|
| 311 |
[temp.deduct.guide]: temp.md#temp.deduct.guide
|
| 312 |
[temp.dep]: temp.md#temp.dep
|
| 313 |
[temp.dep.candidate]: temp.md#temp.dep.candidate
|
|
|
|
|
|
|
| 314 |
[temp.expl.spec]: temp.md#temp.expl.spec
|
| 315 |
[temp.explicit]: temp.md#temp.explicit
|
|
|
|
| 316 |
[temp.local]: temp.md#temp.local
|
| 317 |
[temp.names]: temp.md#temp.names
|
| 318 |
-
[temp.nondep]: temp.md#temp.nondep
|
| 319 |
[temp.over]: temp.md#temp.over
|
|
|
|
| 320 |
[temp.param]: temp.md#temp.param
|
| 321 |
[temp.point]: temp.md#temp.point
|
| 322 |
[temp.pre]: temp.md#temp.pre
|
| 323 |
[temp.res]: temp.md#temp.res
|
| 324 |
[temp.spec]: temp.md#temp.spec
|
|
|
|
| 325 |
[temp.type]: temp.md#temp.type
|
|
|
|
|
|
|
|
|
|
| 326 |
[thread]: thread.md#thread
|
| 327 |
[thread.jthread.class]: thread.md#thread.jthread.class
|
| 328 |
[thread.thread.class]: thread.md#thread.thread.class
|
| 329 |
[thread.threads]: thread.md#thread.threads
|
| 330 |
-
[util.dynamic.safety]: utilities.md#util.dynamic.safety
|
| 331 |
|
| 332 |
[^1]: Appearing inside the brace-enclosed *declaration-seq* in a
|
| 333 |
*linkage-specification* does not affect whether a declaration is a
|
| 334 |
definition.
|
| 335 |
|
| 336 |
[^2]: An implementation is not required to call allocation and
|
| 337 |
deallocation functions from constructors or destructors; however,
|
| 338 |
this is a permissible implementation technique.
|
| 339 |
|
| 340 |
-
[^3]:
|
| 341 |
-
|
| 342 |
-
used in the function body.
|
| 343 |
|
| 344 |
-
[^4]:
|
| 345 |
-
name may be used in a *base-specifier* or in the
|
| 346 |
-
*member-specification* of the class definition.
|
| 347 |
-
|
| 348 |
-
[^5]: This lookup applies whether the definition of `X` is nested within
|
| 349 |
-
`Y`’s definition or whether `X`’s definition appears in a namespace
|
| 350 |
-
scope enclosing `Y`’s definition [[class.nest]].
|
| 351 |
-
|
| 352 |
-
[^6]: That is, an unqualified name that occurs, for instance, in a type
|
| 353 |
-
in the *parameter-declaration-clause* or in the
|
| 354 |
-
*noexcept-specifier*.
|
| 355 |
-
|
| 356 |
-
[^7]: This lookup applies whether the member function is defined within
|
| 357 |
-
the definition of class `X` or whether the member function is
|
| 358 |
-
defined in a namespace scope enclosing `X`’s definition.
|
| 359 |
-
|
| 360 |
-
[^8]: Lookups in which function names are ignored include names
|
| 361 |
appearing in a *nested-name-specifier*, an
|
| 362 |
*elaborated-type-specifier*, or a *base-specifier*.
|
| 363 |
|
| 364 |
-
[^
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
in the header `<climits>`.
|
| 366 |
|
| 367 |
-
[^
|
| 368 |
objects at the same machine address or not store an object at all if
|
| 369 |
the program cannot observe the difference [[intro.execution]].
|
| 370 |
|
| 371 |
-
[^
|
| 372 |
-
|
| 373 |
|
| 374 |
-
[^
|
| 375 |
implicitly—upon exit from the block for an object with automatic
|
| 376 |
storage duration, upon exit from the thread for an object with
|
| 377 |
thread storage duration, or upon exit from the program for an object
|
| 378 |
with static storage duration.
|
| 379 |
|
| 380 |
-
[^
|
| 381 |
value causes a system-generated runtime fault.
|
| 382 |
|
| 383 |
-
[^
|
| 384 |
`std::malloc()` or `std::calloc()`, so the rules are substantially
|
| 385 |
the same. C++ differs from C in requiring a zero request to return a
|
| 386 |
non-null pointer.
|
| 387 |
|
| 388 |
-
[^
|
| 389 |
an allocation function `void operator new(std::size_t, std::size_t)`
|
| 390 |
-
as a placement allocation function
|
| 391 |
|
| 392 |
-
[^
|
| 393 |
-
through pointers to memory not allocated by `::operator new`. This
|
| 394 |
-
maintains the ability of many C++ implementations to use binary
|
| 395 |
-
libraries and components written in other languages. In particular,
|
| 396 |
-
this applies to C binaries, because indirection through pointers to
|
| 397 |
-
memory allocated by `std::malloc` is not restricted.
|
| 398 |
-
|
| 399 |
-
[^17]: The same rules apply to initialization of an `initializer_list`
|
| 400 |
object [[dcl.init.list]] with its underlying temporary array.
|
| 401 |
|
| 402 |
-
[^
|
| 403 |
`std::memcpy` or `std::memmove`.
|
| 404 |
|
| 405 |
-
[^
|
| 406 |
`std::memcpy` or `std::memmove`.
|
| 407 |
|
| 408 |
-
[^
|
| 409 |
that of ISO/IEC 9899 Programming Language C.
|
| 410 |
|
| 411 |
-
[^
|
| 412 |
object type is unknown.
|
| 413 |
|
| 414 |
-
[^
|
| 415 |
|
| 416 |
-
[^
|
| 417 |
them are ordinary pointers to objects or functions.
|
| 418 |
|
| 419 |
-
[^
|
| 420 |
byte in memory that it will occupy or used to occupy.
|
| 421 |
|
| 422 |
-
[^
|
| 423 |
imply interchangeability as arguments to functions, return values
|
| 424 |
from functions, and non-static data members of unions.
|
| 425 |
|
| 426 |
-
[^
|
| 427 |
evaluated, a sequence of zero or more invocations of destructor
|
| 428 |
functions for temporary objects takes place, usually in reverse
|
| 429 |
order of the construction of each temporary object.
|
| 430 |
|
| 431 |
-
[^
|
| 432 |
other.
|
| 433 |
|
| 434 |
-
[^
|
| 435 |
is associated with one specific thread, and can be accessed by a
|
| 436 |
different thread only indirectly through a pointer or reference
|
| 437 |
[[basic.compound]].
|
| 438 |
|
| 439 |
-
[^
|
| 440 |
initialization with side effects is initialized in this case, even
|
| 441 |
-
if it is not itself odr-used
|
| 442 |
-
[[basic.stc.static]]).
|
|
|
|
| 23 |
storage duration is sequenced before that of another, the completion of
|
| 24 |
the destructor of the second is sequenced before the initiation of the
|
| 25 |
destructor of the first. If an object is initialized statically, the
|
| 26 |
object is destroyed in the same order as if the object was dynamically
|
| 27 |
initialized. For an object of array or class type, all subobjects of
|
| 28 |
+
that object are destroyed before any block variable with static storage
|
| 29 |
+
duration initialized during the construction of the subobjects is
|
| 30 |
+
destroyed. If the destruction of an object with static or thread storage
|
| 31 |
+
duration exits via an exception, the function `std::terminate` is called
|
| 32 |
+
[[except.terminate]].
|
| 33 |
|
| 34 |
+
If a function contains a block variable of static or thread storage
|
| 35 |
duration that has been destroyed and the function is called during the
|
| 36 |
destruction of an object with static or thread storage duration, the
|
| 37 |
program has undefined behavior if the flow of control passes through the
|
| 38 |
+
definition of the previously destroyed block variable.
|
| 39 |
+
|
| 40 |
+
[*Note 2*: Likewise, the behavior is undefined if the block variable is
|
| 41 |
+
used indirectly (e.g., through a pointer) after its
|
| 42 |
+
destruction. — *end note*]
|
| 43 |
|
| 44 |
If the completion of the initialization of an object with static storage
|
| 45 |
duration strongly happens before a call to `std::atexit` (see
|
| 46 |
`<cstdlib>`, [[support.start.term]]), the call to the function passed to
|
| 47 |
`std::atexit` is sequenced before the call to the destructor for the
|
|
|
|
| 58 |
within signal handlers [[support.runtime]] that does not happen before
|
| 59 |
[[intro.multithread]] completion of destruction of objects with static
|
| 60 |
storage duration and execution of `std::atexit` registered functions
|
| 61 |
[[support.start.term]], the program has undefined behavior.
|
| 62 |
|
| 63 |
+
[*Note 3*: If there is a use of an object with static storage duration
|
| 64 |
that does not happen before the object’s destruction, the program has
|
| 65 |
undefined behavior. Terminating every thread before a call to
|
| 66 |
`std::exit` or the exit from `main` is sufficient, but not necessary, to
|
| 67 |
satisfy these requirements. These requirements permit thread managers as
|
| 68 |
static-storage-duration objects. — *end note*]
|
|
|
|
| 70 |
Calling the function `std::abort()` declared in `<cstdlib>` terminates
|
| 71 |
the program without executing any destructors and without calling the
|
| 72 |
functions passed to `std::atexit()` or `std::at_quick_exit()`.
|
| 73 |
|
| 74 |
<!-- Link reference definitions -->
|
| 75 |
+
[allocator.members]: mem.md#allocator.members
|
| 76 |
+
[allocator.traits.members]: mem.md#allocator.traits.members
|
| 77 |
+
[atomics]: thread.md#atomics
|
| 78 |
+
[atomics.flag]: thread.md#atomics.flag
|
| 79 |
+
[atomics.lockfree]: thread.md#atomics.lockfree
|
| 80 |
+
[atomics.order]: thread.md#atomics.order
|
| 81 |
[bad.alloc]: support.md#bad.alloc
|
| 82 |
[basic]: #basic
|
| 83 |
[basic.align]: #basic.align
|
| 84 |
[basic.compound]: #basic.compound
|
| 85 |
[basic.def]: #basic.def
|
| 86 |
[basic.def.odr]: #basic.def.odr
|
| 87 |
[basic.exec]: #basic.exec
|
| 88 |
+
[basic.extended.fp]: #basic.extended.fp
|
| 89 |
[basic.fundamental]: #basic.fundamental
|
| 90 |
[basic.fundamental.width]: #basic.fundamental.width
|
|
|
|
| 91 |
[basic.indet]: #basic.indet
|
| 92 |
[basic.life]: #basic.life
|
| 93 |
[basic.link]: #basic.link
|
| 94 |
[basic.lookup]: #basic.lookup
|
| 95 |
[basic.lookup.argdep]: #basic.lookup.argdep
|
|
|
|
| 96 |
[basic.lookup.elab]: #basic.lookup.elab
|
| 97 |
+
[basic.lookup.general]: #basic.lookup.general
|
| 98 |
[basic.lookup.qual]: #basic.lookup.qual
|
| 99 |
+
[basic.lookup.qual.general]: #basic.lookup.qual.general
|
| 100 |
[basic.lookup.udir]: #basic.lookup.udir
|
| 101 |
[basic.lookup.unqual]: #basic.lookup.unqual
|
| 102 |
[basic.lval]: expr.md#basic.lval
|
| 103 |
[basic.memobj]: #basic.memobj
|
| 104 |
[basic.namespace]: dcl.md#basic.namespace
|
| 105 |
[basic.pre]: #basic.pre
|
| 106 |
[basic.scope]: #basic.scope
|
| 107 |
[basic.scope.block]: #basic.scope.block
|
| 108 |
[basic.scope.class]: #basic.scope.class
|
|
|
|
| 109 |
[basic.scope.enum]: #basic.scope.enum
|
| 110 |
+
[basic.scope.lambda]: #basic.scope.lambda
|
| 111 |
[basic.scope.namespace]: #basic.scope.namespace
|
| 112 |
[basic.scope.param]: #basic.scope.param
|
| 113 |
[basic.scope.pdecl]: #basic.scope.pdecl
|
| 114 |
+
[basic.scope.scope]: #basic.scope.scope
|
| 115 |
[basic.scope.temp]: #basic.scope.temp
|
| 116 |
[basic.start]: #basic.start
|
| 117 |
[basic.start.dynamic]: #basic.start.dynamic
|
| 118 |
[basic.start.main]: #basic.start.main
|
| 119 |
[basic.start.static]: #basic.start.static
|
|
|
|
| 121 |
[basic.stc]: #basic.stc
|
| 122 |
[basic.stc.auto]: #basic.stc.auto
|
| 123 |
[basic.stc.dynamic]: #basic.stc.dynamic
|
| 124 |
[basic.stc.dynamic.allocation]: #basic.stc.dynamic.allocation
|
| 125 |
[basic.stc.dynamic.deallocation]: #basic.stc.dynamic.deallocation
|
| 126 |
+
[basic.stc.dynamic.general]: #basic.stc.dynamic.general
|
| 127 |
+
[basic.stc.general]: #basic.stc.general
|
| 128 |
[basic.stc.inherit]: #basic.stc.inherit
|
| 129 |
[basic.stc.static]: #basic.stc.static
|
| 130 |
[basic.stc.thread]: #basic.stc.thread
|
| 131 |
[basic.type.qualifier]: #basic.type.qualifier
|
| 132 |
[basic.type.qualifier.rel]: #basic.type.qualifier.rel
|
| 133 |
[basic.types]: #basic.types
|
| 134 |
+
[basic.types.general]: #basic.types.general
|
| 135 |
+
[bit.cast]: utilities.md#bit.cast
|
| 136 |
+
[c.malloc]: mem.md#c.malloc
|
| 137 |
[class]: class.md#class
|
| 138 |
[class.abstract]: class.md#class.abstract
|
| 139 |
[class.access]: class.md#class.access
|
| 140 |
+
[class.access.base]: class.md#class.access.base
|
| 141 |
[class.base.init]: class.md#class.base.init
|
| 142 |
[class.bit]: class.md#class.bit
|
| 143 |
[class.cdtor]: class.md#class.cdtor
|
| 144 |
[class.conv.fct]: class.md#class.conv.fct
|
| 145 |
[class.copy.assign]: class.md#class.copy.assign
|
|
|
|
| 148 |
[class.default.ctor]: class.md#class.default.ctor
|
| 149 |
[class.derived]: class.md#class.derived
|
| 150 |
[class.dtor]: class.md#class.dtor
|
| 151 |
[class.free]: class.md#class.free
|
| 152 |
[class.friend]: class.md#class.friend
|
|
|
|
| 153 |
[class.mem]: class.md#class.mem
|
| 154 |
+
[class.member.lookup]: #class.member.lookup
|
| 155 |
[class.mfct]: class.md#class.mfct
|
| 156 |
+
[class.mfct.non.static]: class.md#class.mfct.non.static
|
| 157 |
[class.name]: class.md#class.name
|
|
|
|
| 158 |
[class.pre]: class.md#class.pre
|
| 159 |
[class.prop]: class.md#class.prop
|
| 160 |
[class.qual]: #class.qual
|
| 161 |
[class.spaceship]: class.md#class.spaceship
|
| 162 |
[class.static]: class.md#class.static
|
| 163 |
[class.static.data]: class.md#class.static.data
|
| 164 |
[class.temporary]: #class.temporary
|
|
|
|
| 165 |
[class.union]: class.md#class.union
|
| 166 |
+
[class.union.anon]: class.md#class.union.anon
|
| 167 |
[class.virtual]: class.md#class.virtual
|
| 168 |
[conv]: expr.md#conv
|
| 169 |
[conv.array]: expr.md#conv.array
|
| 170 |
[conv.func]: expr.md#conv.func
|
| 171 |
[conv.integral]: expr.md#conv.integral
|
|
|
|
| 193 |
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 194 |
[dcl.init]: dcl.md#dcl.init
|
| 195 |
[dcl.init.aggr]: dcl.md#dcl.init.aggr
|
| 196 |
[dcl.init.list]: dcl.md#dcl.init.list
|
| 197 |
[dcl.init.ref]: dcl.md#dcl.init.ref
|
|
|
|
| 198 |
[dcl.link]: dcl.md#dcl.link
|
| 199 |
[dcl.meaning]: dcl.md#dcl.meaning
|
| 200 |
[dcl.mptr]: dcl.md#dcl.mptr
|
| 201 |
[dcl.name]: dcl.md#dcl.name
|
| 202 |
[dcl.pre]: dcl.md#dcl.pre
|
|
|
|
| 204 |
[dcl.ref]: dcl.md#dcl.ref
|
| 205 |
[dcl.spec]: dcl.md#dcl.spec
|
| 206 |
[dcl.spec.auto]: dcl.md#dcl.spec.auto
|
| 207 |
[dcl.stc]: dcl.md#dcl.stc
|
| 208 |
[dcl.struct.bind]: dcl.md#dcl.struct.bind
|
| 209 |
+
[dcl.type.decltype]: dcl.md#dcl.type.decltype
|
| 210 |
[dcl.type.elab]: dcl.md#dcl.type.elab
|
| 211 |
[dcl.typedef]: dcl.md#dcl.typedef
|
| 212 |
[defns.block]: intro.md#defns.block
|
|
|
|
|
|
|
| 213 |
[depr.local]: future.md#depr.local
|
| 214 |
[depr.static.constexpr]: future.md#depr.static.constexpr
|
| 215 |
[diff.cpp11.basic]: compatibility.md#diff.cpp11.basic
|
| 216 |
[enum.udecl]: dcl.md#enum.udecl
|
| 217 |
[except.handle]: except.md#except.handle
|
| 218 |
[except.pre]: except.md#except.pre
|
| 219 |
[except.spec]: except.md#except.spec
|
| 220 |
[except.terminate]: except.md#except.terminate
|
| 221 |
[except.throw]: except.md#except.throw
|
|
|
|
| 222 |
[expr.add]: expr.md#expr.add
|
| 223 |
[expr.alignof]: expr.md#expr.alignof
|
| 224 |
[expr.arith.conv]: expr.md#expr.arith.conv
|
| 225 |
[expr.ass]: expr.md#expr.ass
|
| 226 |
[expr.await]: expr.md#expr.await
|
| 227 |
[expr.call]: expr.md#expr.call
|
| 228 |
[expr.cast]: expr.md#expr.cast
|
| 229 |
[expr.comma]: expr.md#expr.comma
|
|
|
|
| 230 |
[expr.cond]: expr.md#expr.cond
|
| 231 |
[expr.const]: expr.md#expr.const
|
| 232 |
[expr.const.cast]: expr.md#expr.const.cast
|
| 233 |
[expr.context]: expr.md#expr.context
|
| 234 |
[expr.delete]: expr.md#expr.delete
|
|
|
|
| 238 |
[expr.log.or]: expr.md#expr.log.or
|
| 239 |
[expr.mptr.oper]: expr.md#expr.mptr.oper
|
| 240 |
[expr.new]: expr.md#expr.new
|
| 241 |
[expr.pre]: expr.md#expr.pre
|
| 242 |
[expr.prim.id]: expr.md#expr.prim.id
|
|
|
|
| 243 |
[expr.prim.id.qual]: expr.md#expr.prim.id.qual
|
| 244 |
+
[expr.prim.id.unqual]: expr.md#expr.prim.id.unqual
|
| 245 |
[expr.prim.lambda]: expr.md#expr.prim.lambda
|
| 246 |
[expr.prim.lambda.capture]: expr.md#expr.prim.lambda.capture
|
| 247 |
[expr.prim.lambda.closure]: expr.md#expr.prim.lambda.closure
|
| 248 |
[expr.prim.this]: expr.md#expr.prim.this
|
| 249 |
[expr.prop]: expr.md#expr.prop
|
|
|
|
| 259 |
[get.new.handler]: support.md#get.new.handler
|
| 260 |
[headers]: library.md#headers
|
| 261 |
[intro.execution]: #intro.execution
|
| 262 |
[intro.memory]: #intro.memory
|
| 263 |
[intro.multithread]: #intro.multithread
|
| 264 |
+
[intro.multithread.general]: #intro.multithread.general
|
| 265 |
[intro.object]: #intro.object
|
| 266 |
[intro.progress]: #intro.progress
|
| 267 |
[intro.races]: #intro.races
|
| 268 |
[lex.charset]: lex.md#lex.charset
|
| 269 |
+
[lex.fcon]: lex.md#lex.fcon
|
| 270 |
[lex.name]: lex.md#lex.name
|
| 271 |
[lex.separate]: lex.md#lex.separate
|
|
|
|
|
|
|
| 272 |
[module.context]: module.md#module.context
|
| 273 |
[module.global.frag]: module.md#module.global.frag
|
|
|
|
| 274 |
[module.interface]: module.md#module.interface
|
| 275 |
[module.reach]: module.md#module.reach
|
| 276 |
[module.unit]: module.md#module.unit
|
| 277 |
[multibyte.strings]: library.md#multibyte.strings
|
| 278 |
[namespace.def]: dcl.md#namespace.def
|
|
|
|
| 279 |
[namespace.qual]: #namespace.qual
|
| 280 |
[namespace.udecl]: dcl.md#namespace.udecl
|
| 281 |
[namespace.udir]: dcl.md#namespace.udir
|
| 282 |
+
[namespace.unnamed]: dcl.md#namespace.unnamed
|
| 283 |
[new.delete]: support.md#new.delete
|
| 284 |
[new.delete.array]: support.md#new.delete.array
|
| 285 |
[new.delete.placement]: support.md#new.delete.placement
|
| 286 |
[new.delete.single]: support.md#new.delete.single
|
| 287 |
[new.handler]: support.md#new.handler
|
| 288 |
+
[new.syn]: support.md#new.syn
|
| 289 |
+
[obj.lifetime]: mem.md#obj.lifetime
|
| 290 |
[over]: over.md#over
|
| 291 |
[over.literal]: over.md#over.literal
|
| 292 |
[over.match]: over.md#over.match
|
| 293 |
+
[over.match.funcs]: over.md#over.match.funcs
|
| 294 |
[over.oper]: over.md#over.oper
|
| 295 |
[over.over]: over.md#over.over
|
| 296 |
+
[ptr.align]: mem.md#ptr.align
|
| 297 |
[ptr.launder]: support.md#ptr.launder
|
| 298 |
[replacement.functions]: library.md#replacement.functions
|
| 299 |
[special]: class.md#special
|
| 300 |
+
[std.modules]: library.md#std.modules
|
| 301 |
+
[stdfloat.syn]: support.md#stdfloat.syn
|
| 302 |
[stmt.block]: stmt.md#stmt.block
|
| 303 |
[stmt.dcl]: stmt.md#stmt.dcl
|
| 304 |
[stmt.expr]: stmt.md#stmt.expr
|
|
|
|
| 305 |
[stmt.if]: stmt.md#stmt.if
|
| 306 |
+
[stmt.iter]: stmt.md#stmt.iter
|
| 307 |
+
[stmt.pre]: stmt.md#stmt.pre
|
| 308 |
[stmt.ranged]: stmt.md#stmt.ranged
|
| 309 |
[stmt.return]: stmt.md#stmt.return
|
| 310 |
+
[stmt.select]: stmt.md#stmt.select
|
| 311 |
[support.dynamic]: support.md#support.dynamic
|
|
|
|
| 312 |
[support.runtime]: support.md#support.runtime
|
| 313 |
[support.start.term]: support.md#support.start.term
|
| 314 |
[support.types]: support.md#support.types
|
| 315 |
+
[temp.concept]: temp.md#temp.concept
|
| 316 |
[temp.deduct.guide]: temp.md#temp.deduct.guide
|
| 317 |
[temp.dep]: temp.md#temp.dep
|
| 318 |
[temp.dep.candidate]: temp.md#temp.dep.candidate
|
| 319 |
+
[temp.dep.constexpr]: temp.md#temp.dep.constexpr
|
| 320 |
+
[temp.dep.type]: temp.md#temp.dep.type
|
| 321 |
[temp.expl.spec]: temp.md#temp.expl.spec
|
| 322 |
[temp.explicit]: temp.md#temp.explicit
|
| 323 |
+
[temp.friend]: temp.md#temp.friend
|
| 324 |
[temp.local]: temp.md#temp.local
|
| 325 |
[temp.names]: temp.md#temp.names
|
|
|
|
| 326 |
[temp.over]: temp.md#temp.over
|
| 327 |
+
[temp.over.link]: temp.md#temp.over.link
|
| 328 |
[temp.param]: temp.md#temp.param
|
| 329 |
[temp.point]: temp.md#temp.point
|
| 330 |
[temp.pre]: temp.md#temp.pre
|
| 331 |
[temp.res]: temp.md#temp.res
|
| 332 |
[temp.spec]: temp.md#temp.spec
|
| 333 |
+
[temp.spec.partial]: temp.md#temp.spec.partial
|
| 334 |
[temp.type]: temp.md#temp.type
|
| 335 |
+
[term.incomplete.type]: #term.incomplete.type
|
| 336 |
+
[term.odr.use]: #term.odr.use
|
| 337 |
+
[term.unevaluated.operand]: expr.md#term.unevaluated.operand
|
| 338 |
[thread]: thread.md#thread
|
| 339 |
[thread.jthread.class]: thread.md#thread.jthread.class
|
| 340 |
[thread.thread.class]: thread.md#thread.thread.class
|
| 341 |
[thread.threads]: thread.md#thread.threads
|
|
|
|
| 342 |
|
| 343 |
[^1]: Appearing inside the brace-enclosed *declaration-seq* in a
|
| 344 |
*linkage-specification* does not affect whether a declaration is a
|
| 345 |
definition.
|
| 346 |
|
| 347 |
[^2]: An implementation is not required to call allocation and
|
| 348 |
deallocation functions from constructors or destructors; however,
|
| 349 |
this is a permissible implementation technique.
|
| 350 |
|
| 351 |
+
[^3]: An implicit object parameter [[over.match.funcs]] is not part of
|
| 352 |
+
the parameter-type-list.
|
|
|
|
| 353 |
|
| 354 |
+
[^4]: Lookups in which function names are ignored include names
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
appearing in a *nested-name-specifier*, an
|
| 356 |
*elaborated-type-specifier*, or a *base-specifier*.
|
| 357 |
|
| 358 |
+
[^5]: Unicode® is a registered trademark of Unicode, Inc. This
|
| 359 |
+
information is given for the convenience of users of this document
|
| 360 |
+
and does not constitute an endorsement by ISO or IEC of this
|
| 361 |
+
product.
|
| 362 |
+
|
| 363 |
+
[^6]: The number of bits in a byte is reported by the macro `CHAR_BIT`
|
| 364 |
in the header `<climits>`.
|
| 365 |
|
| 366 |
+
[^7]: Under the “as-if” rule an implementation is allowed to store two
|
| 367 |
objects at the same machine address or not store an object at all if
|
| 368 |
the program cannot observe the difference [[intro.execution]].
|
| 369 |
|
| 370 |
+
[^8]: For example, before the dynamic initialization of an object with
|
| 371 |
+
static storage duration [[basic.start.dynamic]].
|
| 372 |
|
| 373 |
+
[^9]: That is, an object for which a destructor will be called
|
| 374 |
implicitly—upon exit from the block for an object with automatic
|
| 375 |
storage duration, upon exit from the thread for an object with
|
| 376 |
thread storage duration, or upon exit from the program for an object
|
| 377 |
with static storage duration.
|
| 378 |
|
| 379 |
+
[^10]: Some implementations might define that copying an invalid pointer
|
| 380 |
value causes a system-generated runtime fault.
|
| 381 |
|
| 382 |
+
[^11]: The intent is to have `operator new()` implementable by calling
|
| 383 |
`std::malloc()` or `std::calloc()`, so the rules are substantially
|
| 384 |
the same. C++ differs from C in requiring a zero request to return a
|
| 385 |
non-null pointer.
|
| 386 |
|
| 387 |
+
[^12]: The global `operator delete(void*, std::size_t)` precludes use of
|
| 388 |
an allocation function `void operator new(std::size_t, std::size_t)`
|
| 389 |
+
as a placement allocation function [[diff.cpp11.basic]].
|
| 390 |
|
| 391 |
+
[^13]: The same rules apply to initialization of an `initializer_list`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 392 |
object [[dcl.init.list]] with its underlying temporary array.
|
| 393 |
|
| 394 |
+
[^14]: By using, for example, the library functions [[headers]]
|
| 395 |
`std::memcpy` or `std::memmove`.
|
| 396 |
|
| 397 |
+
[^15]: By using, for example, the library functions [[headers]]
|
| 398 |
`std::memcpy` or `std::memmove`.
|
| 399 |
|
| 400 |
+
[^16]: The intent is that the memory model of C++ is compatible with
|
| 401 |
that of ISO/IEC 9899 Programming Language C.
|
| 402 |
|
| 403 |
+
[^17]: The size and layout of an instance of an incompletely-defined
|
| 404 |
object type is unknown.
|
| 405 |
|
| 406 |
+
[^18]: This is also known as two’s complement representation.
|
| 407 |
|
| 408 |
+
[^19]: Static class members are objects or functions, and pointers to
|
| 409 |
them are ordinary pointers to objects or functions.
|
| 410 |
|
| 411 |
+
[^20]: For an object that is not within its lifetime, this is the first
|
| 412 |
byte in memory that it will occupy or used to occupy.
|
| 413 |
|
| 414 |
+
[^21]: The same representation and alignment requirements are meant to
|
| 415 |
imply interchangeability as arguments to functions, return values
|
| 416 |
from functions, and non-static data members of unions.
|
| 417 |
|
| 418 |
+
[^22]: As specified in [[class.temporary]], after a full-expression is
|
| 419 |
evaluated, a sequence of zero or more invocations of destructor
|
| 420 |
functions for temporary objects takes place, usually in reverse
|
| 421 |
order of the construction of each temporary object.
|
| 422 |
|
| 423 |
+
[^23]: In other words, function executions do not interleave with each
|
| 424 |
other.
|
| 425 |
|
| 426 |
+
[^24]: An object with automatic or thread storage duration [[basic.stc]]
|
| 427 |
is associated with one specific thread, and can be accessed by a
|
| 428 |
different thread only indirectly through a pointer or reference
|
| 429 |
[[basic.compound]].
|
| 430 |
|
| 431 |
+
[^25]: A non-block variable with static storage duration having
|
| 432 |
initialization with side effects is initialized in this case, even
|
| 433 |
+
if it is not itself odr-used [[term.odr.use]], [[basic.stc.static]].
|
|
|