From 7279c105acf41437e74b134b5d23dbb58f8c591e Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Thu, 6 Apr 2017 23:24:25 +0200 Subject: [PATCH 1/2] Remove \tcode from 'const object'. Fixes #469. --- source/basic.tex | 6 +++--- source/compatibility.tex | 8 ++++---- source/conversions.tex | 4 ++-- source/declarations.tex | 14 +++++++------- source/expressions.tex | 4 ++-- source/intro.tex | 2 +- source/templates.tex | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/source/basic.tex b/source/basic.tex index 5315542c9a..dee2b39faf 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -446,7 +446,7 @@ template specialization\iref{temp.over}, except that a name can refer to \begin{itemize} \item -a non-volatile \tcode{const} object with internal or no linkage if the object +a non-volatile const object with internal or no linkage if the object \begin{itemize} \item has the same literal type in all definitions of \tcode{D}, \item is initialized with a constant expression\iref{expr.const}, @@ -2926,9 +2926,9 @@ \end{example} \pnum -Creating a new object within the storage that a \tcode{const} complete +Creating a new object within the storage that a const complete object with static, thread, or automatic storage duration occupies, -or within the storage that such a \tcode{const} object used to occupy before +or within the storage that such a const object used to occupy before its lifetime ended, results in undefined behavior. \begin{example} \begin{codeblock} diff --git a/source/compatibility.tex b/source/compatibility.tex index 4ceb1fe85f..45711ce1a7 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -150,10 +150,10 @@ \change A name of file scope that is explicitly declared \tcode{const}, and not explicitly declared \tcode{extern}, has internal linkage, while in C it would have external linkage. \rationale -Because \tcode{const} objects may be used as values during translation in +Because const objects may be used as values during translation in \Cpp, this feature urges programmers to provide an explicit initializer -for each \tcode{const} object. -This feature allows the user to put \tcode{const} objects in source files that are included +for each const object. +This feature allows the user to put const objects in source files that are included in more than one translation unit. \effect Change to semantics of well-defined feature. @@ -422,7 +422,7 @@ Seldom. \ref{dcl.type} [see also \ref{basic.link}] -\change \tcode{const} objects must be initialized in \Cpp but can be left uninitialized in C. +\change const objects must be initialized in \Cpp but can be left uninitialized in C. \rationale A const object cannot be assigned to so it must be initialized to hold a useful value. diff --git a/source/conversions.tex b/source/conversions.tex index fb97829c13..53af129488 100644 --- a/source/conversions.tex +++ b/source/conversions.tex @@ -298,7 +298,7 @@ \begin{note} If a program could assign a pointer of type \tcode{T**} to a pointer of type \tcode{const} \tcode{T**} (that is, if line \#1 below were -allowed), a program could inadvertently modify a \tcode{const} object +allowed), a program could inadvertently modify a const object (as it is done on line \#2). For example, \begin{codeblock} @@ -307,7 +307,7 @@ char* pc; const char** pcc = &pc; // \#1: not allowed *pcc = &c; - *pc = 'C'; // \#2: modifies a \tcode{const} object + *pc = 'C'; // \#2: modifies a const object } \end{codeblock} \end{note} diff --git a/source/declarations.tex b/source/declarations.tex index ea5061cd5f..00e105bd34 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -486,7 +486,7 @@ The \tcode{mutable} specifier on a class data member nullifies a \tcode{const} specifier applied to the containing class object and permits modification of the mutable class member even though the rest of -the object is \tcode{const}\iref{dcl.type.cv}. +the object is const\iref{dcl.type.cv}. \rSec2[dcl.fct.spec]{Function specifiers}% \indextext{specifier!function}% @@ -943,7 +943,7 @@ \pnum A \tcode{constexpr} specifier used in an object declaration -declares the object as \tcode{const}. +declares the object as const. Such an object shall have literal type and shall be initialized. @@ -1154,9 +1154,9 @@ \end{note} \pnum -\indextext{const object@\tcode{const}-object!undefined change to}% +\indextext{const object@const-object!undefined change to}% Except that any class member declared \tcode{mutable}\iref{dcl.stc} -can be modified, any attempt to modify a \tcode{const} object during its +can be modified, any attempt to modify a const object during its lifetime\iref{basic.life} results in undefined behavior. \begin{example} \begin{codeblock} @@ -1170,11 +1170,11 @@ int* ip; ip = const_cast(cip); // cast needed to convert \tcode{const int*} to \tcode{int*} -*ip = 4; // defined: \tcode{*ip} points to \tcode{i}, a non-\tcode{const} object +*ip = 4; // defined: \tcode{*ip} points to \tcode{i}, a non-const object const int* ciq = new const int (3); // initialized as required int* iq = const_cast(ciq); // cast required -*iq = 4; // undefined: modifies a \tcode{const} object +*iq = 4; // undefined: modifies a const object \end{codeblock} For another example, \begin{codeblock} @@ -1192,7 +1192,7 @@ y.x.j++; // ill-formed: const-qualified member modified Y* p = const_cast(&y); // cast away const-ness of \tcode{y} p->x.i = 99; // well-formed: \tcode{mutable} member can be modified -p->x.j = 99; // undefined: modifies a \tcode{const} member +p->x.j = 99; // undefined: modifies a const subobject \end{codeblock} \end{example} diff --git a/source/expressions.tex b/source/expressions.tex index 609f66d9c7..8cf23ca64d 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -4525,7 +4525,7 @@ \tcode{E1.E2} given in~\ref{expr.ref}. \begin{note} It is not possible to use a pointer to member that refers to a -\tcode{mutable} member to modify a \tcode{const} class object. For +\tcode{mutable} member to modify a const class object. For example, \begin{codeblock} @@ -4537,7 +4537,7 @@ { const S cs; int S::* pm = &S::i; // \tcode{pm} refers to \tcode{mutable} member \tcode{S::i} -cs.*pm = 88; // ill-formed: \tcode{cs} is a \tcode{const} object +cs.*pm = 88; // ill-formed: \tcode{cs} is a const object } \end{codeblock} \end{note} diff --git a/source/intro.tex b/source/intro.tex index 57e8158826..1b5748e239 100644 --- a/source/intro.tex +++ b/source/intro.tex @@ -494,7 +494,7 @@ \pnum Certain other operations are described in this document as undefined (for example, the effect of -attempting to modify a \tcode{const} object). +attempting to modify a const object). \begin{note} This document imposes no requirements on the behavior of programs that contain undefined behavior. \end{note} diff --git a/source/templates.tex b/source/templates.tex index 04245bb9fb..4a7b170b6a 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -4148,7 +4148,7 @@ \item constant expression evaluation\iref{expr.const} within the template instantiation uses \begin{itemize} - \item the value of a \tcode{const} object of integral or unscoped enumeration type or + \item the value of a const object of integral or unscoped enumeration type or \item the value of a \tcode{constexpr} object or \item the value of a reference or \item the definition of a constexpr function, From f57d46a5b22d0095d87bc3b52960a867d530a369 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 11 Nov 2017 22:28:51 -0800 Subject: [PATCH 2/2] Update declarations.tex --- source/declarations.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/declarations.tex b/source/declarations.tex index 00e105bd34..9647eb689c 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -1154,7 +1154,7 @@ \end{note} \pnum -\indextext{const object@const-object!undefined change to}% +\indextext{const object!undefined change to}% Except that any class member declared \tcode{mutable}\iref{dcl.stc} can be modified, any attempt to modify a const object during its lifetime\iref{basic.life} results in undefined behavior.