- tmp/tmpevwzeif0/{from.md → to.md} +18 -351
tmp/tmpevwzeif0/{from.md → to.md}
RENAMED
|
@@ -1,20 +1,20 @@
|
|
| 1 |
-
## Alignment <a id="basic.align">[[basic.align]]</a>
|
| 2 |
|
| 3 |
-
Object types have *alignment requirements*
|
| 4 |
[[basic.compound]]) which place restrictions on the addresses at which
|
| 5 |
an object of that type may be allocated. An *alignment* is an
|
| 6 |
*implementation-defined* integer value representing the number of bytes
|
| 7 |
between successive addresses at which a given object can be allocated.
|
| 8 |
An object type imposes an alignment requirement on every object of that
|
| 9 |
-
type; stricter alignment can be requested using the alignment
|
| 10 |
-
|
| 11 |
|
| 12 |
A *fundamental alignment* is represented by an alignment less than or
|
| 13 |
equal to the greatest alignment supported by the implementation in all
|
| 14 |
-
contexts, which is equal to `alignof(std::max_align_t)`
|
| 15 |
-
[[support.types]]
|
| 16 |
when it is used as the type of a complete object and when it is used as
|
| 17 |
the type of a subobject.
|
| 18 |
|
| 19 |
[*Example 1*:
|
| 20 |
|
|
@@ -35,19 +35,19 @@ The result of the `alignof` operator reflects the alignment requirement
|
|
| 35 |
of the type in the complete-object case.
|
| 36 |
|
| 37 |
An *extended alignment* is represented by an alignment greater than
|
| 38 |
`alignof(std::max_align_t)`. It is *implementation-defined* whether any
|
| 39 |
extended alignments are supported and the contexts in which they are
|
| 40 |
-
supported
|
| 41 |
-
|
| 42 |
|
| 43 |
[*Note 1*: Every over-aligned type is or contains a class type to which
|
| 44 |
extended alignment applies (possibly through a non-static data
|
| 45 |
member). — *end note*]
|
| 46 |
|
| 47 |
A *new-extended alignment* is represented by an alignment greater than
|
| 48 |
-
`__STDCPP_DEFAULT_NEW_ALIGNMENT__`
|
| 49 |
|
| 50 |
Alignments are represented as values of the type `std::size_t`. Valid
|
| 51 |
alignments include only those values returned by an `alignof` expression
|
| 52 |
for the fundamental types plus an additional *implementation-defined*
|
| 53 |
set of values, which may be empty. Every alignment value shall be a
|
|
@@ -57,360 +57,27 @@ Alignments have an order from *weaker* to *stronger* or *stricter*
|
|
| 57 |
alignments. Stricter alignments have larger alignment values. An address
|
| 58 |
that satisfies an alignment requirement also satisfies any weaker valid
|
| 59 |
alignment requirement.
|
| 60 |
|
| 61 |
The alignment requirement of a complete type can be queried using an
|
| 62 |
-
`alignof` expression
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
-
[*Note 2*: This enables the
|
| 67 |
-
underlying type for an aligned memory area
|
| 68 |
-
[[dcl.align]]). — *end note*]
|
| 69 |
|
| 70 |
Comparing alignments is meaningful and provides the obvious results:
|
| 71 |
|
| 72 |
- Two alignments are equal when their numeric values are equal.
|
| 73 |
- Two alignments are different when their numeric values are not equal.
|
| 74 |
- When an alignment is larger than another it represents a stricter
|
| 75 |
alignment.
|
| 76 |
|
| 77 |
-
[*Note 3*: The runtime pointer alignment function
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
|
| 82 |
If a request for a specific extended alignment in a specific context is
|
| 83 |
not supported by an implementation, the program is ill-formed.
|
| 84 |
|
| 85 |
-
<!-- Link reference definitions -->
|
| 86 |
-
[bad.alloc]: language.md#bad.alloc
|
| 87 |
-
[basic]: #basic
|
| 88 |
-
[basic.align]: #basic.align
|
| 89 |
-
[basic.compound]: #basic.compound
|
| 90 |
-
[basic.def]: #basic.def
|
| 91 |
-
[basic.def.odr]: #basic.def.odr
|
| 92 |
-
[basic.fundamental]: #basic.fundamental
|
| 93 |
-
[basic.funscope]: #basic.funscope
|
| 94 |
-
[basic.life]: #basic.life
|
| 95 |
-
[basic.link]: #basic.link
|
| 96 |
-
[basic.lookup]: #basic.lookup
|
| 97 |
-
[basic.lookup.argdep]: #basic.lookup.argdep
|
| 98 |
-
[basic.lookup.classref]: #basic.lookup.classref
|
| 99 |
-
[basic.lookup.elab]: #basic.lookup.elab
|
| 100 |
-
[basic.lookup.qual]: #basic.lookup.qual
|
| 101 |
-
[basic.lookup.udir]: #basic.lookup.udir
|
| 102 |
-
[basic.lookup.unqual]: #basic.lookup.unqual
|
| 103 |
-
[basic.lval]: #basic.lval
|
| 104 |
-
[basic.namespace]: dcl.md#basic.namespace
|
| 105 |
-
[basic.scope]: #basic.scope
|
| 106 |
-
[basic.scope.block]: #basic.scope.block
|
| 107 |
-
[basic.scope.class]: #basic.scope.class
|
| 108 |
-
[basic.scope.declarative]: #basic.scope.declarative
|
| 109 |
-
[basic.scope.enum]: #basic.scope.enum
|
| 110 |
-
[basic.scope.hiding]: #basic.scope.hiding
|
| 111 |
-
[basic.scope.namespace]: #basic.scope.namespace
|
| 112 |
-
[basic.scope.pdecl]: #basic.scope.pdecl
|
| 113 |
-
[basic.scope.proto]: #basic.scope.proto
|
| 114 |
-
[basic.scope.temp]: #basic.scope.temp
|
| 115 |
-
[basic.start]: #basic.start
|
| 116 |
-
[basic.start.dynamic]: #basic.start.dynamic
|
| 117 |
-
[basic.start.main]: #basic.start.main
|
| 118 |
-
[basic.start.static]: #basic.start.static
|
| 119 |
-
[basic.start.term]: #basic.start.term
|
| 120 |
-
[basic.stc]: #basic.stc
|
| 121 |
-
[basic.stc.auto]: #basic.stc.auto
|
| 122 |
-
[basic.stc.dynamic]: #basic.stc.dynamic
|
| 123 |
-
[basic.stc.dynamic.allocation]: #basic.stc.dynamic.allocation
|
| 124 |
-
[basic.stc.dynamic.deallocation]: #basic.stc.dynamic.deallocation
|
| 125 |
-
[basic.stc.dynamic.safety]: #basic.stc.dynamic.safety
|
| 126 |
-
[basic.stc.inherit]: #basic.stc.inherit
|
| 127 |
-
[basic.stc.static]: #basic.stc.static
|
| 128 |
-
[basic.stc.thread]: #basic.stc.thread
|
| 129 |
-
[basic.type.qualifier]: #basic.type.qualifier
|
| 130 |
-
[basic.types]: #basic.types
|
| 131 |
-
[class]: class.md#class
|
| 132 |
-
[class.access]: class.md#class.access
|
| 133 |
-
[class.base.init]: special.md#class.base.init
|
| 134 |
-
[class.bit]: class.md#class.bit
|
| 135 |
-
[class.cdtor]: special.md#class.cdtor
|
| 136 |
-
[class.conv.fct]: special.md#class.conv.fct
|
| 137 |
-
[class.copy]: special.md#class.copy
|
| 138 |
-
[class.ctor]: special.md#class.ctor
|
| 139 |
-
[class.derived]: class.md#class.derived
|
| 140 |
-
[class.dtor]: special.md#class.dtor
|
| 141 |
-
[class.free]: special.md#class.free
|
| 142 |
-
[class.friend]: class.md#class.friend
|
| 143 |
-
[class.local]: class.md#class.local
|
| 144 |
-
[class.mem]: class.md#class.mem
|
| 145 |
-
[class.member.lookup]: class.md#class.member.lookup
|
| 146 |
-
[class.mfct]: class.md#class.mfct
|
| 147 |
-
[class.mfct.non-static]: class.md#class.mfct.non-static
|
| 148 |
-
[class.name]: class.md#class.name
|
| 149 |
-
[class.nest]: class.md#class.nest
|
| 150 |
-
[class.qual]: #class.qual
|
| 151 |
-
[class.static]: class.md#class.static
|
| 152 |
-
[class.static.data]: class.md#class.static.data
|
| 153 |
-
[class.temporary]: special.md#class.temporary
|
| 154 |
-
[class.this]: class.md#class.this
|
| 155 |
-
[class.union]: class.md#class.union
|
| 156 |
-
[conv]: conv.md#conv
|
| 157 |
-
[conv.array]: conv.md#conv.array
|
| 158 |
-
[conv.func]: conv.md#conv.func
|
| 159 |
-
[conv.integral]: conv.md#conv.integral
|
| 160 |
-
[conv.lval]: conv.md#conv.lval
|
| 161 |
-
[conv.mem]: conv.md#conv.mem
|
| 162 |
-
[conv.prom]: conv.md#conv.prom
|
| 163 |
-
[conv.ptr]: conv.md#conv.ptr
|
| 164 |
-
[conv.qual]: conv.md#conv.qual
|
| 165 |
-
[conv.rval]: conv.md#conv.rval
|
| 166 |
-
[cpp.predefined]: cpp.md#cpp.predefined
|
| 167 |
-
[cstddef.syn]: language.md#cstddef.syn
|
| 168 |
-
[dcl.align]: dcl.md#dcl.align
|
| 169 |
-
[dcl.array]: dcl.md#dcl.array
|
| 170 |
-
[dcl.dcl]: dcl.md#dcl.dcl
|
| 171 |
-
[dcl.decl]: dcl.md#dcl.decl
|
| 172 |
-
[dcl.enum]: dcl.md#dcl.enum
|
| 173 |
-
[dcl.fct]: dcl.md#dcl.fct
|
| 174 |
-
[dcl.fct.def]: dcl.md#dcl.fct.def
|
| 175 |
-
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 176 |
-
[dcl.init]: dcl.md#dcl.init
|
| 177 |
-
[dcl.init.aggr]: dcl.md#dcl.init.aggr
|
| 178 |
-
[dcl.init.ref]: dcl.md#dcl.init.ref
|
| 179 |
-
[dcl.inline]: dcl.md#dcl.inline
|
| 180 |
-
[dcl.link]: dcl.md#dcl.link
|
| 181 |
-
[dcl.mptr]: dcl.md#dcl.mptr
|
| 182 |
-
[dcl.name]: dcl.md#dcl.name
|
| 183 |
-
[dcl.ptr]: dcl.md#dcl.ptr
|
| 184 |
-
[dcl.ref]: dcl.md#dcl.ref
|
| 185 |
-
[dcl.spec]: dcl.md#dcl.spec
|
| 186 |
-
[dcl.stc]: dcl.md#dcl.stc
|
| 187 |
-
[dcl.type.elab]: dcl.md#dcl.type.elab
|
| 188 |
-
[dcl.type.simple]: dcl.md#dcl.type.simple
|
| 189 |
-
[dcl.typedef]: dcl.md#dcl.typedef
|
| 190 |
-
[depr.static_constexpr]: future.md#depr.static_constexpr
|
| 191 |
-
[diff.cpp11.basic]: compatibility.md#diff.cpp11.basic
|
| 192 |
-
[except]: except.md#except
|
| 193 |
-
[except.handle]: except.md#except.handle
|
| 194 |
-
[except.spec]: except.md#except.spec
|
| 195 |
-
[except.terminate]: except.md#except.terminate
|
| 196 |
-
[except.throw]: except.md#except.throw
|
| 197 |
-
[expr]: expr.md#expr
|
| 198 |
-
[expr.add]: expr.md#expr.add
|
| 199 |
-
[expr.alignof]: expr.md#expr.alignof
|
| 200 |
-
[expr.ass]: expr.md#expr.ass
|
| 201 |
-
[expr.call]: expr.md#expr.call
|
| 202 |
-
[expr.cast]: expr.md#expr.cast
|
| 203 |
-
[expr.comma]: expr.md#expr.comma
|
| 204 |
-
[expr.cond]: expr.md#expr.cond
|
| 205 |
-
[expr.const]: expr.md#expr.const
|
| 206 |
-
[expr.delete]: expr.md#expr.delete
|
| 207 |
-
[expr.dynamic.cast]: expr.md#expr.dynamic.cast
|
| 208 |
-
[expr.eq]: expr.md#expr.eq
|
| 209 |
-
[expr.mptr.oper]: expr.md#expr.mptr.oper
|
| 210 |
-
[expr.new]: expr.md#expr.new
|
| 211 |
-
[expr.post.incr]: expr.md#expr.post.incr
|
| 212 |
-
[expr.pre.incr]: expr.md#expr.pre.incr
|
| 213 |
-
[expr.prim]: expr.md#expr.prim
|
| 214 |
-
[expr.prim.id]: expr.md#expr.prim.id
|
| 215 |
-
[expr.prim.lambda.closure]: expr.md#expr.prim.lambda.closure
|
| 216 |
-
[expr.pseudo]: expr.md#expr.pseudo
|
| 217 |
-
[expr.ref]: expr.md#expr.ref
|
| 218 |
-
[expr.reinterpret.cast]: expr.md#expr.reinterpret.cast
|
| 219 |
-
[expr.rel]: expr.md#expr.rel
|
| 220 |
-
[expr.sizeof]: expr.md#expr.sizeof
|
| 221 |
-
[expr.static.cast]: expr.md#expr.static.cast
|
| 222 |
-
[expr.sub]: expr.md#expr.sub
|
| 223 |
-
[expr.type.conv]: expr.md#expr.type.conv
|
| 224 |
-
[expr.typeid]: expr.md#expr.typeid
|
| 225 |
-
[expr.unary.op]: expr.md#expr.unary.op
|
| 226 |
-
[fig:categories]: #fig:categories
|
| 227 |
-
[headers]: library.md#headers
|
| 228 |
-
[intro.execution]: intro.md#intro.execution
|
| 229 |
-
[intro.memory]: intro.md#intro.memory
|
| 230 |
-
[intro.multithread]: intro.md#intro.multithread
|
| 231 |
-
[intro.object]: intro.md#intro.object
|
| 232 |
-
[intro.races]: intro.md#intro.races
|
| 233 |
-
[lex]: lex.md#lex
|
| 234 |
-
[lex.name]: lex.md#lex.name
|
| 235 |
-
[locale]: localization.md#locale
|
| 236 |
-
[meta.trans.other]: utilities.md#meta.trans.other
|
| 237 |
-
[multibyte.strings]: library.md#multibyte.strings
|
| 238 |
-
[namespace.alias]: dcl.md#namespace.alias
|
| 239 |
-
[namespace.def]: dcl.md#namespace.def
|
| 240 |
-
[namespace.memdef]: dcl.md#namespace.memdef
|
| 241 |
-
[namespace.qual]: #namespace.qual
|
| 242 |
-
[namespace.udecl]: dcl.md#namespace.udecl
|
| 243 |
-
[namespace.udir]: dcl.md#namespace.udir
|
| 244 |
-
[new.delete]: language.md#new.delete
|
| 245 |
-
[new.delete.array]: language.md#new.delete.array
|
| 246 |
-
[new.delete.placement]: language.md#new.delete.placement
|
| 247 |
-
[new.delete.single]: language.md#new.delete.single
|
| 248 |
-
[new.handler]: language.md#new.handler
|
| 249 |
-
[over]: over.md#over
|
| 250 |
-
[over.literal]: over.md#over.literal
|
| 251 |
-
[over.load]: over.md#over.load
|
| 252 |
-
[over.match]: over.md#over.match
|
| 253 |
-
[over.oper]: over.md#over.oper
|
| 254 |
-
[over.over]: over.md#over.over
|
| 255 |
-
[ptr.align]: utilities.md#ptr.align
|
| 256 |
-
[replacement.functions]: library.md#replacement.functions
|
| 257 |
-
[set.new.handler]: language.md#set.new.handler
|
| 258 |
-
[stmt.block]: stmt.md#stmt.block
|
| 259 |
-
[stmt.dcl]: stmt.md#stmt.dcl
|
| 260 |
-
[stmt.expr]: stmt.md#stmt.expr
|
| 261 |
-
[stmt.goto]: stmt.md#stmt.goto
|
| 262 |
-
[stmt.if]: stmt.md#stmt.if
|
| 263 |
-
[stmt.label]: stmt.md#stmt.label
|
| 264 |
-
[stmt.return]: stmt.md#stmt.return
|
| 265 |
-
[stmt.select]: stmt.md#stmt.select
|
| 266 |
-
[support.dynamic]: language.md#support.dynamic
|
| 267 |
-
[support.limits]: language.md#support.limits
|
| 268 |
-
[support.runtime]: language.md#support.runtime
|
| 269 |
-
[support.start.term]: language.md#support.start.term
|
| 270 |
-
[support.types]: language.md#support.types
|
| 271 |
-
[tab:relations.on.const.and.volatile]: #tab:relations.on.const.and.volatile
|
| 272 |
-
[temp]: temp.md#temp
|
| 273 |
-
[temp.class.spec]: temp.md#temp.class.spec
|
| 274 |
-
[temp.deduct.guide]: temp.md#temp.deduct.guide
|
| 275 |
-
[temp.dep]: temp.md#temp.dep
|
| 276 |
-
[temp.expl.spec]: temp.md#temp.expl.spec
|
| 277 |
-
[temp.explicit]: temp.md#temp.explicit
|
| 278 |
-
[temp.fct]: temp.md#temp.fct
|
| 279 |
-
[temp.local]: temp.md#temp.local
|
| 280 |
-
[temp.mem.func]: temp.md#temp.mem.func
|
| 281 |
-
[temp.names]: temp.md#temp.names
|
| 282 |
-
[temp.nondep]: temp.md#temp.nondep
|
| 283 |
-
[temp.over]: temp.md#temp.over
|
| 284 |
-
[temp.over.link]: temp.md#temp.over.link
|
| 285 |
-
[temp.param]: temp.md#temp.param
|
| 286 |
-
[temp.point]: temp.md#temp.point
|
| 287 |
-
[temp.res]: temp.md#temp.res
|
| 288 |
-
[temp.spec]: temp.md#temp.spec
|
| 289 |
-
[temp.static]: temp.md#temp.static
|
| 290 |
-
[temp.type]: temp.md#temp.type
|
| 291 |
-
[thread.threads]: thread.md#thread.threads
|
| 292 |
-
[util.dynamic.safety]: utilities.md#util.dynamic.safety
|
| 293 |
-
|
| 294 |
-
[^1]: Appearing inside the braced-enclosed *declaration-seq* in a
|
| 295 |
-
*linkage-specification* does not affect whether a declaration is a
|
| 296 |
-
definition.
|
| 297 |
-
|
| 298 |
-
[^2]: An implementation is not required to call allocation and
|
| 299 |
-
deallocation functions from constructors or destructors; however,
|
| 300 |
-
this is a permissible implementation technique.
|
| 301 |
-
|
| 302 |
-
[^3]: [[dcl.fct.default]] describes how default argument names are
|
| 303 |
-
looked up.
|
| 304 |
-
|
| 305 |
-
[^4]: This refers to unqualified names that occur, for instance, in a
|
| 306 |
-
type or default argument in the *parameter-declaration-clause* or
|
| 307 |
-
used in the function body.
|
| 308 |
-
|
| 309 |
-
[^5]: This refers to unqualified names following the class name; such a
|
| 310 |
-
name may be used in the *base-clause* or may be used in the class
|
| 311 |
-
definition.
|
| 312 |
-
|
| 313 |
-
[^6]: This lookup applies whether the definition of `X` is nested within
|
| 314 |
-
`Y`’s definition or whether `X`’s definition appears in a namespace
|
| 315 |
-
scope enclosing `Y`’s definition ([[class.nest]]).
|
| 316 |
-
|
| 317 |
-
[^7]: That is, an unqualified name that occurs, for instance, in a type
|
| 318 |
-
in the *parameter-declaration-clause* or in the
|
| 319 |
-
*noexcept-specifier*.
|
| 320 |
-
|
| 321 |
-
[^8]: This lookup applies whether the member function is defined within
|
| 322 |
-
the definition of class `X` or whether the member function is
|
| 323 |
-
defined in a namespace scope enclosing `X`’s definition.
|
| 324 |
-
|
| 325 |
-
[^9]: Lookups in which function names are ignored include names
|
| 326 |
-
appearing in a *nested-name-specifier*, an
|
| 327 |
-
*elaborated-type-specifier*, or a *base-specifier*.
|
| 328 |
-
|
| 329 |
-
[^10]: A class template has the linkage of the innermost enclosing class
|
| 330 |
-
or namespace in which it is declared.
|
| 331 |
-
|
| 332 |
-
[^11]: A non-local variable with static storage duration having
|
| 333 |
-
initialization with side effects is initialized in this case, even
|
| 334 |
-
if it is not itself odr-used ([[basic.def.odr]],
|
| 335 |
-
[[basic.stc.static]]).
|
| 336 |
-
|
| 337 |
-
[^12]: Some implementations might define that copying an invalid pointer
|
| 338 |
-
value causes a system-generated runtime fault.
|
| 339 |
-
|
| 340 |
-
[^13]: The intent is to have `operator new()` implementable by calling
|
| 341 |
-
`std::malloc()` or `std::calloc()`, so the rules are substantially
|
| 342 |
-
the same. C++differs from C in requiring a zero request to return a
|
| 343 |
-
non-null pointer.
|
| 344 |
-
|
| 345 |
-
[^14]: The global `operator delete(void*, std::size_t)` precludes use of
|
| 346 |
-
an allocation function `void operator new(std::size_t, std::size_t)`
|
| 347 |
-
as a placement allocation function ([[diff.cpp11.basic]]).
|
| 348 |
-
|
| 349 |
-
[^15]: This section does not impose restrictions on indirection through
|
| 350 |
-
pointers to memory not allocated by `::operator new`. This maintains
|
| 351 |
-
the ability of many C++implementations to use binary libraries and
|
| 352 |
-
components written in other languages. In particular, this applies
|
| 353 |
-
to C binaries, because indirection through pointers to memory
|
| 354 |
-
allocated by `std::malloc` is not restricted.
|
| 355 |
-
|
| 356 |
-
[^16]: For example, before the construction of a global object of
|
| 357 |
-
non-POD class type ([[class.cdtor]]).
|
| 358 |
-
|
| 359 |
-
[^17]: That is, an object for which a destructor will be called
|
| 360 |
-
implicitly—upon exit from the block for an object with automatic
|
| 361 |
-
storage duration, upon exit from the thread for an object with
|
| 362 |
-
thread storage duration, or upon exit from the program for an object
|
| 363 |
-
with static storage duration.
|
| 364 |
-
|
| 365 |
-
[^18]: By using, for example, the library functions ([[headers]])
|
| 366 |
-
`std::memcpy` or `std::memmove`.
|
| 367 |
-
|
| 368 |
-
[^19]: By using, for example, the library functions ([[headers]])
|
| 369 |
-
`std::memcpy` or `std::memmove`.
|
| 370 |
-
|
| 371 |
-
[^20]: The intent is that the memory model of C++is compatible with that
|
| 372 |
-
of ISO/IEC 9899 Programming Language C.
|
| 373 |
-
|
| 374 |
-
[^21]: The size and layout of an instance of an incompletely-defined
|
| 375 |
-
object type is unknown.
|
| 376 |
-
|
| 377 |
-
[^22]: `int` must also be large enough to contain any value in the range
|
| 378 |
-
\[`INT_MIN`, `INT_MAX`\], as defined in the header `<climits>`.
|
| 379 |
-
|
| 380 |
-
[^23]: See [[dcl.type.simple]] regarding the correspondence between
|
| 381 |
-
types and the sequences of *type-specifier*s that designate them.
|
| 382 |
-
|
| 383 |
-
[^24]: This implies that unsigned arithmetic does not overflow because a
|
| 384 |
-
result that cannot be represented by the resulting unsigned integer
|
| 385 |
-
type is reduced modulo the number that is one greater than the
|
| 386 |
-
largest value that can be represented by the resulting unsigned
|
| 387 |
-
integer type.
|
| 388 |
-
|
| 389 |
-
[^25]: Using a `bool` value in ways described by this International
|
| 390 |
-
Standard as “undefined”, such as by examining the value of an
|
| 391 |
-
uninitialized automatic object, might cause it to behave as if it is
|
| 392 |
-
neither `true` nor `false`.
|
| 393 |
-
|
| 394 |
-
[^26]: Therefore, enumerations ([[dcl.enum]]) are not integral;
|
| 395 |
-
however, enumerations can be promoted to integral types as specified
|
| 396 |
-
in [[conv.prom]].
|
| 397 |
-
|
| 398 |
-
[^27]: A positional representation for integers that uses the binary
|
| 399 |
-
digits 0 and 1, in which the values represented by successive bits
|
| 400 |
-
are additive, begin with 1, and are multiplied by successive
|
| 401 |
-
integral power of 2, except perhaps for the bit with the highest
|
| 402 |
-
position. (Adapted from the *American National Dictionary for
|
| 403 |
-
Information Processing Systems*.)
|
| 404 |
-
|
| 405 |
-
[^28]: Static class members are objects or functions, and pointers to
|
| 406 |
-
them are ordinary pointers to objects or functions.
|
| 407 |
-
|
| 408 |
-
[^29]: For an object that is not within its lifetime, this is the first
|
| 409 |
-
byte in memory that it will occupy or used to occupy.
|
| 410 |
-
|
| 411 |
-
[^30]: The same representation and alignment requirements are meant to
|
| 412 |
-
imply interchangeability as arguments to functions, return values
|
| 413 |
-
from functions, and non-static data members of unions.
|
| 414 |
-
|
| 415 |
-
[^31]: The intent of this list is to specify those circumstances in
|
| 416 |
-
which an object may or may not be aliased.
|
|
|
|
| 1 |
+
### Alignment <a id="basic.align">[[basic.align]]</a>
|
| 2 |
|
| 3 |
+
Object types have *alignment requirements* ([[basic.fundamental]],
|
| 4 |
[[basic.compound]]) which place restrictions on the addresses at which
|
| 5 |
an object of that type may be allocated. An *alignment* is an
|
| 6 |
*implementation-defined* integer value representing the number of bytes
|
| 7 |
between successive addresses at which a given object can be allocated.
|
| 8 |
An object type imposes an alignment requirement on every object of that
|
| 9 |
+
type; stricter alignment can be requested using the alignment specifier
|
| 10 |
+
[[dcl.align]].
|
| 11 |
|
| 12 |
A *fundamental alignment* is represented by an alignment less than or
|
| 13 |
equal to the greatest alignment supported by the implementation in all
|
| 14 |
+
contexts, which is equal to `alignof(std::max_align_t)`
|
| 15 |
+
[[support.types]]. The alignment required for a type might be different
|
| 16 |
when it is used as the type of a complete object and when it is used as
|
| 17 |
the type of a subobject.
|
| 18 |
|
| 19 |
[*Example 1*:
|
| 20 |
|
|
|
|
| 35 |
of the type in the complete-object case.
|
| 36 |
|
| 37 |
An *extended alignment* is represented by an alignment greater than
|
| 38 |
`alignof(std::max_align_t)`. It is *implementation-defined* whether any
|
| 39 |
extended alignments are supported and the contexts in which they are
|
| 40 |
+
supported [[dcl.align]]. A type having an extended alignment requirement
|
| 41 |
+
is an *over-aligned type*.
|
| 42 |
|
| 43 |
[*Note 1*: Every over-aligned type is or contains a class type to which
|
| 44 |
extended alignment applies (possibly through a non-static data
|
| 45 |
member). — *end note*]
|
| 46 |
|
| 47 |
A *new-extended alignment* is represented by an alignment greater than
|
| 48 |
+
`__STDCPP_DEFAULT_NEW_ALIGNMENT__` [[cpp.predefined]].
|
| 49 |
|
| 50 |
Alignments are represented as values of the type `std::size_t`. Valid
|
| 51 |
alignments include only those values returned by an `alignof` expression
|
| 52 |
for the fundamental types plus an additional *implementation-defined*
|
| 53 |
set of values, which may be empty. Every alignment value shall be a
|
|
|
|
| 57 |
alignments. Stricter alignments have larger alignment values. An address
|
| 58 |
that satisfies an alignment requirement also satisfies any weaker valid
|
| 59 |
alignment requirement.
|
| 60 |
|
| 61 |
The alignment requirement of a complete type can be queried using an
|
| 62 |
+
`alignof` expression [[expr.alignof]]. Furthermore, the narrow character
|
| 63 |
+
types [[basic.fundamental]] shall have the weakest alignment
|
| 64 |
+
requirement.
|
| 65 |
|
| 66 |
+
[*Note 2*: This enables the ordinary character types to be used as the
|
| 67 |
+
underlying type for an aligned memory area [[dcl.align]]. — *end note*]
|
|
|
|
| 68 |
|
| 69 |
Comparing alignments is meaningful and provides the obvious results:
|
| 70 |
|
| 71 |
- Two alignments are equal when their numeric values are equal.
|
| 72 |
- Two alignments are different when their numeric values are not equal.
|
| 73 |
- When an alignment is larger than another it represents a stricter
|
| 74 |
alignment.
|
| 75 |
|
| 76 |
+
[*Note 3*: The runtime pointer alignment function [[ptr.align]] can be
|
| 77 |
+
used to obtain an aligned pointer within a buffer; the aligned-storage
|
| 78 |
+
templates in the library [[meta.trans.other]] can be used to obtain
|
| 79 |
+
aligned storage. — *end note*]
|
| 80 |
|
| 81 |
If a request for a specific extended alignment in a specific context is
|
| 82 |
not supported by an implementation, the program is ill-formed.
|
| 83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|