Skip to content

Commit 541cd8c

Browse files
committed
[basic.memobj] Provide a logic progression of subclauses
Simplified a comprehensive change to just move Alignment to follow the object model.
1 parent 8b24d3d commit 541cd8c

File tree

1 file changed

+94
-94
lines changed

1 file changed

+94
-94
lines changed

source/basic.tex

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,6 +3454,100 @@
34543454
\end{note}
34553455
\indextext{object model|)}
34563456

3457+
\rSec2[basic.align]{Alignment}
3458+
3459+
\pnum
3460+
Object types have \defnx{alignment requirements}{alignment requirement!implementation-defined}\iref{basic.fundamental,basic.compound}
3461+
which place restrictions on the addresses at which an object of that type
3462+
may be allocated. An \defn{alignment} is an \impldef{alignment}
3463+
integer value representing the number of bytes between successive addresses
3464+
at which a given object can be allocated. An object type imposes an alignment
3465+
requirement on every object of that type; stricter alignment can be requested
3466+
using the alignment specifier\iref{dcl.align}.
3467+
Attempting to create an object\iref{intro.object} in storage that
3468+
does not meet the alignment requirements of the object's type
3469+
is undefined behavior.
3470+
3471+
\pnum
3472+
A \defnadj{fundamental}{alignment} is represented by an alignment
3473+
less than or equal to the greatest alignment supported by the implementation in
3474+
all contexts, which is equal to
3475+
\tcode{\keyword{alignof}(std::max_align_t)}\iref{support.types}.
3476+
The alignment required for a type may be different when it is used as the type
3477+
of a complete object and when it is used as the type of a subobject.
3478+
\begin{example}
3479+
\begin{codeblock}
3480+
struct B { long double d; };
3481+
struct D : virtual B { char c; };
3482+
\end{codeblock}
3483+
3484+
When \tcode{D} is the type of a complete object, it will have a subobject of
3485+
type \tcode{B}, so it must be aligned appropriately for a \tcode{\keyword{long} \keyword{double}}.
3486+
If \tcode{D} appears as a subobject of another object that also has \tcode{B}
3487+
as a virtual base class, the \tcode{B} subobject might be part of a different
3488+
subobject, reducing the alignment requirements on the \tcode{D} subobject.
3489+
\end{example}
3490+
The result of the \keyword{alignof} operator reflects the alignment
3491+
requirement of the type in the complete-object case.
3492+
3493+
\pnum
3494+
An \defnadj{extended}{alignment} is represented by an alignment
3495+
greater than \tcode{\keyword{alignof}(std::max_align_t)}. It is \impldef{support for extended alignments}
3496+
whether any extended alignments are supported and the contexts in which they are
3497+
supported\iref{dcl.align}. A type having an extended alignment
3498+
requirement is an \defnadj{over-aligned}{type}.
3499+
\begin{note}
3500+
Every over-aligned type is or contains a class type
3501+
to which extended alignment applies (possibly through a non-static data member).
3502+
\end{note}
3503+
A \defnadj{new-extended}{alignment} is represented by
3504+
an alignment greater than \mname{STDCPP_DEFAULT_NEW_ALIGNMENT}\iref{cpp.predefined}.
3505+
3506+
\pnum
3507+
Alignments are represented as values of the type \tcode{std::size_t}.
3508+
Valid alignments include only those values returned by an \keyword{alignof}
3509+
expression for the fundamental types plus an additional \impldef{alignment additional
3510+
values}
3511+
set of values, which may be empty.
3512+
Every alignment value shall be a non-negative integral power of two.
3513+
3514+
\pnum
3515+
Alignments have an order from \defnx{weaker}{alignment!weaker} to
3516+
\defnx{stronger}{alignment!stronger} or \defnx{stricter}{alignment!stricter} alignments. Stricter
3517+
alignments have larger alignment values. An address that satisfies an alignment
3518+
requirement also satisfies any weaker valid alignment requirement.
3519+
3520+
\pnum
3521+
The alignment requirement of a complete type can be queried using an
3522+
\keyword{alignof} expression\iref{expr.alignof}. Furthermore,
3523+
the narrow character types\iref{basic.fundamental} shall have the weakest
3524+
alignment requirement.
3525+
\begin{note}
3526+
This enables the ordinary character types to be used as the
3527+
underlying type for an aligned memory area\iref{dcl.align}.
3528+
\end{note}
3529+
3530+
\pnum
3531+
Comparing alignments is meaningful and provides the obvious results:
3532+
3533+
\begin{itemize}
3534+
\item Two alignments are equal when their numeric values are equal.
3535+
\item Two alignments are different when their numeric values are not equal.
3536+
\item When an alignment is larger than another it represents a stricter alignment.
3537+
\end{itemize}
3538+
3539+
\pnum
3540+
\begin{note}
3541+
The runtime pointer alignment function\iref{ptr.align}
3542+
can be used to obtain an aligned pointer within a buffer;
3543+
an \grammarterm{alignment-specifier}\iref{dcl.align}
3544+
can be used to align storage explicitly.
3545+
\end{note}
3546+
3547+
\pnum
3548+
If a request for a specific extended alignment in a specific context is not
3549+
supported by an implementation, the program is ill-formed.
3550+
34573551
\rSec2[basic.life]{Lifetime}
34583552

34593553
\pnum
@@ -4252,100 +4346,6 @@
42524346
is that of their complete object\iref{intro.object}.
42534347
\indextext{storage duration|)}%
42544348

4255-
\rSec2[basic.align]{Alignment}
4256-
4257-
\pnum
4258-
Object types have \defnx{alignment requirements}{alignment requirement!implementation-defined}\iref{basic.fundamental,basic.compound}
4259-
which place restrictions on the addresses at which an object of that type
4260-
may be allocated. An \defn{alignment} is an \impldef{alignment}
4261-
integer value representing the number of bytes between successive addresses
4262-
at which a given object can be allocated. An object type imposes an alignment
4263-
requirement on every object of that type; stricter alignment can be requested
4264-
using the alignment specifier\iref{dcl.align}.
4265-
Attempting to create an object\iref{intro.object} in storage that
4266-
does not meet the alignment requirements of the object's type
4267-
is undefined behavior.
4268-
4269-
\pnum
4270-
A \defnadj{fundamental}{alignment} is represented by an alignment
4271-
less than or equal to the greatest alignment supported by the implementation in
4272-
all contexts, which is equal to
4273-
\tcode{\keyword{alignof}(std::max_align_t)}\iref{support.types}.
4274-
The alignment required for a type may be different when it is used as the type
4275-
of a complete object and when it is used as the type of a subobject.
4276-
\begin{example}
4277-
\begin{codeblock}
4278-
struct B { long double d; };
4279-
struct D : virtual B { char c; };
4280-
\end{codeblock}
4281-
4282-
When \tcode{D} is the type of a complete object, it will have a subobject of
4283-
type \tcode{B}, so it must be aligned appropriately for a \tcode{\keyword{long} \keyword{double}}.
4284-
If \tcode{D} appears as a subobject of another object that also has \tcode{B}
4285-
as a virtual base class, the \tcode{B} subobject might be part of a different
4286-
subobject, reducing the alignment requirements on the \tcode{D} subobject.
4287-
\end{example}
4288-
The result of the \keyword{alignof} operator reflects the alignment
4289-
requirement of the type in the complete-object case.
4290-
4291-
\pnum
4292-
An \defnadj{extended}{alignment} is represented by an alignment
4293-
greater than \tcode{\keyword{alignof}(std::max_align_t)}. It is \impldef{support for extended alignments}
4294-
whether any extended alignments are supported and the contexts in which they are
4295-
supported\iref{dcl.align}. A type having an extended alignment
4296-
requirement is an \defnadj{over-aligned}{type}.
4297-
\begin{note}
4298-
Every over-aligned type is or contains a class type
4299-
to which extended alignment applies (possibly through a non-static data member).
4300-
\end{note}
4301-
A \defnadj{new-extended}{alignment} is represented by
4302-
an alignment greater than \mname{STDCPP_DEFAULT_NEW_ALIGNMENT}\iref{cpp.predefined}.
4303-
4304-
\pnum
4305-
Alignments are represented as values of the type \tcode{std::size_t}.
4306-
Valid alignments include only those values returned by an \keyword{alignof}
4307-
expression for the fundamental types plus an additional \impldef{alignment additional
4308-
values}
4309-
set of values, which may be empty.
4310-
Every alignment value shall be a non-negative integral power of two.
4311-
4312-
\pnum
4313-
Alignments have an order from \defnx{weaker}{alignment!weaker} to
4314-
\defnx{stronger}{alignment!stronger} or \defnx{stricter}{alignment!stricter} alignments. Stricter
4315-
alignments have larger alignment values. An address that satisfies an alignment
4316-
requirement also satisfies any weaker valid alignment requirement.
4317-
4318-
\pnum
4319-
The alignment requirement of a complete type can be queried using an
4320-
\keyword{alignof} expression\iref{expr.alignof}. Furthermore,
4321-
the narrow character types\iref{basic.fundamental} shall have the weakest
4322-
alignment requirement.
4323-
\begin{note}
4324-
This enables the ordinary character types to be used as the
4325-
underlying type for an aligned memory area\iref{dcl.align}.
4326-
\end{note}
4327-
4328-
\pnum
4329-
Comparing alignments is meaningful and provides the obvious results:
4330-
4331-
\begin{itemize}
4332-
\item Two alignments are equal when their numeric values are equal.
4333-
\item Two alignments are different when their numeric values are not equal.
4334-
\item When an alignment is larger than another it represents a stricter alignment.
4335-
\end{itemize}
4336-
4337-
\pnum
4338-
\begin{note}
4339-
The runtime pointer alignment function\iref{ptr.align}
4340-
can be used to obtain an aligned pointer within a buffer;
4341-
an \grammarterm{alignment-specifier}\iref{dcl.align}
4342-
can be used to align storage explicitly.
4343-
\end{note}
4344-
4345-
\pnum
4346-
If a request for a specific extended alignment in a specific context is not
4347-
supported by an implementation, the program is ill-formed.
4348-
43494349
\rSec2[class.temporary]{Temporary objects}
43504350

43514351
\pnum

0 commit comments

Comments
 (0)