diff --git a/source/basic.tex b/source/basic.tex index a06c1d79e3..e154c791fa 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -1012,10 +1012,10 @@ \begin{example} \begin{codeblock} if (int x = f()) { - int x; // ill-formed, redeclaration of \tcode{x} + int x; // error: redeclaration of \tcode{x} } else { - int x; // ill-formed, redeclaration of \tcode{x} + int x; // error: redeclaration of \tcode{x} } \end{codeblock} \end{example} @@ -1958,9 +1958,9 @@ } void test() { auto x = make(); // OK, \tcode{decltype(x)} is \tcode{R::X} in module \tcode{M} - R::f(x); // ill-formed: \tcode{R} and \tcode{R::f} are not visible here + R::f(x); // error: \tcode{R} and \tcode{R::f} are not visible here f(x); // OK, calls \tcode{R::f} from interface of \tcode{M} - f(x, S::Z()); // ill-formed: \tcode{S::f} in module \tcode{M} not considered + f(x, S::Z()); // error: \tcode{S::f} in module \tcode{M} not considered // even though \tcode{S} is an associated namespace apply(x, S::Z()); // OK, \tcode{S::f} is visible in instantiation context, and // \tcode{R::g} is visible even though it has internal linkage @@ -1996,7 +1996,7 @@ int main() { int A; A::n = 42; // OK - A b; // ill-formed: \tcode{A} does not name a type + A b; // error: \tcode{A} does not name a type } \end{codeblock} \end{example} @@ -2022,7 +2022,7 @@ static const int number = 50; static X arr[number]; }; -X C::arr[number]; // ill-formed: +X C::arr[number]; // error: // equivalent to \tcode{::X} \tcode{C::arr[C::number];} // and not to \tcode{C::X} \tcode{C::arr[C::number];} \end{codeblock} @@ -2149,7 +2149,7 @@ B::B() { } B::A ba; // object of type \tcode{A} -A::A a; // error, \tcode{A::A} is not a type name +A::A a; // error: \tcode{A::A} is not a type name struct A::A a2; // object of type \tcode{A} \end{codeblock} \end{example} @@ -2371,7 +2371,7 @@ } using namespace B; } -void A::f1(int){ } // ill-formed, \tcode{f1} is not a member of \tcode{A} +void A::f1(int){ } // error: \tcode{f1} is not a member of \tcode{A} \end{codeblock} \end{example} However, in such namespace member declarations, the @@ -3288,7 +3288,7 @@ pb->mutate(); *pb; // OK: \tcode{pb} points to valid memory void* q = pb; // OK: \tcode{pb} points to valid memory - pb->f(); // undefined behavior, lifetime of \tcode{*pb} has ended + pb->f(); // undefined behavior: lifetime of \tcode{*pb} has ended } \end{codeblock} \end{example} @@ -4533,8 +4533,8 @@ UNKA** arrpp; void foo() { - xp++; // ill-formed: \tcode{X} is incomplete - arrp++; // ill-formed: incomplete type + xp++; // error: \tcode{X} is incomplete + arrp++; // error: incomplete type arrpp++; // OK: sizeof \tcode{UNKA*} is known } @@ -4544,9 +4544,9 @@ X x; void bar() { xp = &x; // OK; type is ``pointer to \tcode{X}'' - arrp = &arr; // ill-formed: different types + arrp = &arr; // error: different types xp++; // OK: \tcode{X} is complete - arrp++; // ill-formed: \tcode{UNKA} can't be completed + arrp++; // error: \tcode{UNKA} can't be completed } \end{codeblock} \end{example} @@ -5464,7 +5464,7 @@ i = 7, i++, i++; // \tcode{i} becomes \tcode{9} i = i++ + 1; // the value of \tcode{i} is incremented - i = i++ + i; // the behavior is undefined + i = i++ + i; // undefined behavior i = i + 1; // the value of \tcode{i} is incremented } \end{codeblock} diff --git a/source/classes.tex b/source/classes.tex index 0a2e0a2e08..d78b19d7d3 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -318,7 +318,7 @@ simply a single function \tcode{f()} twice. For the same reason, \begin{codeblock} struct S { int a; }; -struct S { int a; }; // error, double definition +struct S { int a; }; // error: double definition \end{codeblock} is ill-formed because it defines \tcode{S} twice. \end{example} @@ -2477,7 +2477,7 @@ }; Y a; -int b = a; // error, \tcode{a.operator X().operator int()} not tried +int b = a; // error: no viable conversion (\tcode{a.operator X().operator int()} not considered) int c = X(a); // OK: \tcode{a.operator X().operator int()} \end{codeblock} \end{example} @@ -2500,7 +2500,7 @@ }; void f(Y& a) { - if (a) { // ill-formed: \tcode{X::operator int()} or \tcode{Y::operator char()} + if (a) { // error: ambiguous between \tcode{X::operator int()} and \tcode{Y::operator char()} } } \end{codeblock} @@ -2643,7 +2643,7 @@ void h(Z z) { Y y1(z); // OK: direct-initialization - Y y2 = z; // ill-formed: copy-initialization + Y y2 = z; // error: no conversion function candidate for copy-initialization Y y3 = (Y)z; // OK: cast notation } @@ -3615,7 +3615,7 @@ \begin{example} \begin{codeblock} class X { @\commentellip@ }; -class Y : public X, public X { @\commentellip@ }; // ill-formed +class Y : public X, public X { @\commentellip@ }; // error \end{codeblock} \begin{codeblock} @@ -3931,7 +3931,7 @@ Derived* dp = &d; D* q = dp->vf4(); // calls \tcode{Derived::vf4()} and does not // convert the result to \tcode{B*} - dp->vf2(); // ill-formed: argument mismatch + dp->vf2(); // error: argument mismatch } \end{codeblock} \end{example} @@ -3989,7 +3989,7 @@ A* ap = b1p; D* dp = &d; ap->f(); // calls \tcode{D::B1::f} - dp->f(); // ill-formed: ambiguous + dp->f(); // error: ambiguous } \end{codeblock} In class \tcode{D} above there are two occurrences of class \tcode{A} @@ -4015,7 +4015,7 @@ void f(); }; -struct Error : VB1, VB2 { // ill-formed +struct Error : VB1, VB2 { // error }; struct Okay : VB1, VB2 { @@ -4130,7 +4130,7 @@ \begin{example} \begin{codeblock} struct C { - virtual void f() = 0 { }; // ill-formed + virtual void f() = 0 { }; // error }; \end{codeblock} \end{example} @@ -4349,7 +4349,7 @@ pd->v++; // OK: only one \tcode{v} (virtual) pd->s++; // OK: only one \tcode{s} (static) int i = pd->e; // OK: only one \tcode{e} (enumerator) - pd->a++; // error, ambiguous: two \tcode{a}{s} in \tcode{D} + pd->a++; // error: ambiguous: two \tcode{a}{s} in \tcode{D} } \end{codeblock} \end{example} @@ -4414,7 +4414,7 @@ void g() { D d; B* pb = &d; - A* pa = &d; // error, ambiguous: \tcode{C}'s \tcode{A} or \tcode{B}'s \tcode{A}? + A* pa = &d; // error: ambiguous: \tcode{C}'s \tcode{A} or \tcode{B}'s \tcode{A}? V* pv = &d; // OK: only one \tcode{V} subobject } \end{codeblock} @@ -5273,7 +5273,7 @@ friend void c(); // error }; X* px; // OK, but \tcode{::X} is found - Z* pz; // error, no \tcode{Z} is found + Z* pz; // error: no \tcode{Z} is found } \end{codeblock} \end{example} @@ -5311,31 +5311,31 @@ }; void fr(B* pb, D1* p1, D2* p2) { - pb->i = 1; // ill-formed - p1->i = 2; // ill-formed + pb->i = 1; // error + p1->i = 2; // error p2->i = 3; // OK (access through a \tcode{D2}) p2->B::i = 4; // OK (access through a \tcode{D2}, even though naming class is \tcode{B}) - int B::* pmi_B = &B::i; // ill-formed + int B::* pmi_B = &B::i; // error int B::* pmi_B2 = &D2::i; // OK (type of \tcode{\&D2::i} is \tcode{int B::*}) - B::j = 5; // ill-formed (not a friend of naming class \tcode{B}) + B::j = 5; // error: not a friend of naming class \tcode{B} D2::j = 6; // OK (because refers to static member) } void D2::mem(B* pb, D1* p1) { - pb->i = 1; // ill-formed - p1->i = 2; // ill-formed + pb->i = 1; // error + p1->i = 2; // error i = 3; // OK (access through \tcode{this}) B::i = 4; // OK (access through \tcode{this}, qualification ignored) - int B::* pmi_B = &B::i; // ill-formed + int B::* pmi_B = &B::i; // error int B::* pmi_B2 = &D2::i; // OK j = 5; // OK (because \tcode{j} refers to static member) B::j = 6; // OK (because \tcode{B::j} refers to static member) } void g(B* pb, D1* p1, D2* p2) { - pb->i = 1; // ill-formed - p1->i = 2; // ill-formed - p2->i = 3; // ill-formed + pb->i = 1; // error + p1->i = 2; // error + p2->i = 3; // error } \end{codeblock} \end{example} @@ -5660,7 +5660,7 @@ struct A { A(); }; struct B: public virtual A { }; struct C: public A, public B { C(); }; -C::C(): A() { } // ill-formed: which \tcode{A}? +C::C(): A() { } // error: which \tcode{A}? \end{codeblock} \end{example} @@ -6019,7 +6019,7 @@ int j; public: int f(); - B() : A(f()), // undefined: calls member function but base \tcode{A} not yet initialized + B() : A(f()), // undefined behavior: calls member function but base \tcode{A} not yet initialized j(f()) { } // well-defined: bases are all initialized }; @@ -6031,7 +6031,7 @@ class D : public B, C { int i; public: - D() : C(f()), // undefined: calls member function but base \tcode{C} not yet initialized + D() : C(f()), // undefined behavior: calls member function but base \tcode{C} not yet initialized i(f()) { } // well-defined: bases are all initialized }; \end{codeblock} @@ -6153,7 +6153,7 @@ using V2::V2; }; -D1 d1(0); // ill-formed: ambiguous +D1 d1(0); // error: ambiguous D2 d2(0); // OK: initializes virtual \tcode{B} base class, which initializes the \tcode{A} base class // then initializes the \tcode{V1} and \tcode{V2} base classes as if by a defaulted default constructor @@ -6193,10 +6193,10 @@ extern B bobj; B* pb = &bobj; // OK -int* p1 = &bobj.a; // undefined, refers to base class member -int* p2 = &bobj.y.i; // undefined, refers to member's member +int* p1 = &bobj.a; // undefined behavior: refers to base class member +int* p2 = &bobj.y.i; // undefined behavior: refers to member's member -A* pa = &bobj; // undefined, upcast to a base class type +A* pa = &bobj; // undefined behavior: upcast to a base class type B bobj; // definition of \tcode{bobj} extern X xobj; @@ -6285,7 +6285,7 @@ struct X { X(A*); }; struct E : C, D, X { - E() : D(this), // undefined: upcast from \tcode{E*} to \tcode{A*} might use path \tcode{E*} $\rightarrow$ \tcode{D*} $\rightarrow$ \tcode{A*} + E() : D(this), // undefined behavior: upcast from \tcode{E*} to \tcode{A*} might use path \tcode{E*} $\rightarrow$ \tcode{D*} $\rightarrow$ \tcode{A*} // but \tcode{D} is not constructed // ``\tcode{D((C*)this)}\!'' would be defined: \tcode{E*} $\rightarrow$ \tcode{C*} is defined because \tcode{E()} has started, @@ -6343,7 +6343,7 @@ f(); // calls \tcode{V::f}, not \tcode{A::f} g(); // calls \tcode{B::g}, not \tcode{D::g} v->g(); // \tcode{v} is base of \tcode{B}, the call is well-defined, calls \tcode{B::g} - a->f(); // undefined behavior, \tcode{a}'s type not a base of \tcode{B} + a->f(); // undefined behavior: \tcode{a}'s type not a base of \tcode{B} } \end{codeblock} \end{example} @@ -6420,7 +6420,7 @@ typeid(*v); // well-defined: \tcode{*v} has type \tcode{V}, a base of \tcode{B} yields \tcode{type_info} for \tcode{B} typeid(*a); // undefined behavior: type \tcode{A} not a base of \tcode{B} dynamic_cast(v); // well-defined: \tcode{v} of type \tcode{V*}, \tcode{V} base of \tcode{B} results in \tcode{B*} - dynamic_cast(a); // undefined behavior, \tcode{a} has type \tcode{A*}, \tcode{A} not a base of \tcode{B} + dynamic_cast(a); // undefined behavior: \tcode{a} has type \tcode{A*}, \tcode{A} not a base of \tcode{B} } \end{codeblock} \end{example} @@ -6963,7 +6963,7 @@ void foo(int i) { new (ap) D1; // calls \tcode{B::operator new(std::size_t, Arena*)} new D1[i]; // calls \tcode{::operator new[](std::size_t)} - new D1; // ill-formed: \tcode{::operator new(std::size_t)} hidden + new D1; // error: \tcode{::operator new(std::size_t)} hidden } \end{codeblock} \end{example} diff --git a/source/compatibility.tex b/source/compatibility.tex index fa19066c66..552bb56630 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -2118,7 +2118,7 @@ int g() { return f(); } // Translation unit 2 -int f(int a = 76) { return a; } // ill-formed (no diagnostic required); previously well-formed +int f(int a = 76) { return a; } // ill-formed, no diagnostic required; previously well-formed int g(); int main() { return g(); } // used to return 42 \end{codeblock} diff --git a/source/declarations.tex b/source/declarations.tex index c20610f69f..a18245ff72 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -155,8 +155,8 @@ declaration. \begin{example} \begin{codeblock} -enum { }; // ill-formed -typedef class { }; // ill-formed +enum { }; // error +typedef class { }; // error \end{codeblock} \end{example} @@ -486,7 +486,7 @@ \begin{codeblock} class X { mutable const int* p; // OK - mutable int* const q; // ill-formed + mutable int* const q; // error }; \end{codeblock} \end{example} @@ -606,7 +606,7 @@ using handler_t = void (*)(int); extern handler_t ignore; extern void (*ignore)(int); // redeclare \tcode{ignore} -using cell = pair; // ill-formed +using cell = pair; // error \end{codeblock} \end{example} The \grammarterm{defining-type-specifier-seq} @@ -1028,7 +1028,7 @@ const char * g() { return "dynamic initialization"; } constexpr const char * f(bool p) { return p ? "constant initializer" : g(); } constinit const char * c = f(true); // OK -constinit const char * d = f(false); // ill-formed +constinit const char * d = f(false); // error \end{codeblock} \end{example} @@ -1257,12 +1257,12 @@ \begin{example} \begin{codeblock} const int ci = 3; // cv-qualified (initialized as required) -ci = 4; // ill-formed: attempt to modify \tcode{const} +ci = 4; // error: attempt to modify \tcode{const} int i = 2; // not cv-qualified const int* cip; // pointer to \tcode{const int} cip = &i; // OK: cv-qualified access path to unqualified -*cip = 4; // ill-formed: attempt to modify through ptr to \tcode{const} +*cip = 4; // error: attempt to modify through ptr to \tcode{const} int* ip; ip = const_cast(cip); // cast needed to convert \tcode{const int*} to \tcode{int*} @@ -1270,7 +1270,7 @@ const int* ciq = new const int (3); // initialized as required int* iq = const_cast(ciq); // cast required -*iq = 4; // undefined: modifies a const object +*iq = 4; // undefined behavior: modifies a const object \end{codeblock} For another example, \begin{codeblock} @@ -1285,10 +1285,10 @@ const Y y; y.x.i++; // well-formed: \tcode{mutable} member can be modified -y.x.j++; // ill-formed: const-qualified member modified +y.x.j++; // error: 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 const subobject +p->x.j = 99; // undefined behavior: modifies a const subobject \end{codeblock} \end{example} @@ -1771,7 +1771,7 @@ \begin{example} \begin{codeblock} auto f() { } // OK, return type is \tcode{void} -auto* g() { } // error, cannot deduce \tcode{auto*} from \tcode{void()} +auto* g() { } // error: cannot deduce \tcode{auto*} from \tcode{void()} \end{codeblock} \end{example} @@ -1794,9 +1794,9 @@ \tcode{return} statements. \begin{example} \begin{codeblock} -auto n = n; // error, \tcode{n}'s initializer refers to \tcode{n} +auto n = n; // error: \tcode{n}'s initializer refers to \tcode{n} auto f(); -void g() { &f; } // error, \tcode{f}'s return type is unknown +void g() { &f; } // error: \tcode{f}'s return type is unknown auto sum(int i) { if (i == 1) return i; // \tcode{sum}'s return type is \tcode{int} @@ -1840,19 +1840,19 @@ auto f(); auto f() { return 42; } // return type is \tcode{int} auto f(); // OK -int f(); // error, cannot be overloaded with \tcode{auto f()} -decltype(auto) f(); // error, \tcode{auto} and \tcode{decltype(auto)} don't match +int f(); // error: cannot be overloaded with \tcode{auto f()} +decltype(auto) f(); // error: \tcode{auto} and \tcode{decltype(auto)} don't match template auto g(T t) { return t; } // \#1 template auto g(int); // OK, return type is \tcode{int} -template char g(char); // error, no matching template +template char g(char); // error: no matching template template<> auto g(double); // OK, forward declaration with unknown return type template T g(T t) { return t; } // OK, not functionally equivalent to \#1 template char g(char); // OK, now there is a matching template template auto g(float); // still matches \#1 -void h() { return g(42); } // error, ambiguous +void h() { return g(42); } // error: ambiguous template struct A { friend T frf(T); @@ -2000,9 +2000,9 @@ auto x5a = f(); // \tcode{decltype(x5a)} is \tcode{int} decltype(auto) x5d = f(); // \tcode{decltype(x5d)} is \tcode{int\&\&} auto x6a = { 1, 2 }; // \tcode{decltype(x6a)} is \tcode{std::initializer_list} -decltype(auto) x6d = { 1, 2 }; // error, \tcode{\{ 1, 2 \}} is not an expression +decltype(auto) x6d = { 1, 2 }; // error: \tcode{\{ 1, 2 \}} is not an expression auto *x7a = &i; // \tcode{decltype(x7a)} is \tcode{int*} -decltype(auto)*x7d = &i; // error, declared type is not plain \tcode{decltype(auto)} +decltype(auto)*x7d = &i; // error: declared type is not plain \tcode{decltype(auto)} \end{codeblock} \end{example} @@ -2068,7 +2068,7 @@ container c(7); // OK, deduces \tcode{int} for \tcode{T} auto d = container(v.begin(), v.end()); // OK, deduces \tcode{double} for \tcode{T} -container e{5, 6}; // error, \tcode{int} is not an iterator +container e{5, 6}; // error: \tcode{int} is not an iterator \end{codeblock} \end{example} \indextext{specifier|)}% @@ -2732,7 +2732,7 @@ \begin{example} \begin{codeblock} typedef int& A; -const A aref = 3; // ill-formed; lvalue reference to non-\tcode{const} initialized with rvalue +const A aref = 3; // error: lvalue reference to non-\tcode{const} initialized with rvalue \end{codeblock} The type of @@ -3412,7 +3412,7 @@ \begin{example} \begin{codeblock} typedef int FIC(int) const; -FIC f; // ill-formed: does not declare a member function +FIC f; // error: does not declare a member function struct S { FIC f; // OK }; @@ -3492,7 +3492,7 @@ \begin{codeblock} typedef void F(); F fv; // OK: equivalent to \tcode{void fv();} -F fv { } // ill-formed +F fv { } // error void fv() { } // OK: definition of \tcode{fv} \end{codeblock} \end{example} @@ -5406,9 +5406,9 @@ struct Alaska { operator Banana&(); }; void enigmatic() { typedef const Banana ConstBanana; - Banana &&banana1 = ConstBanana(); // ill-formed - Banana &&banana2 = Enigma(); // ill-formed - Banana &&banana3 = Alaska(); // ill-formed + Banana &&banana1 = ConstBanana(); // error + Banana &&banana2 = Enigma(); // error + Banana &&banana3 = Alaska(); // error } const double& rcd2 = 2; // \tcode{rcd2} refers to temporary with value \tcode{2.0} @@ -6029,9 +6029,9 @@ \begin{example} \begin{codeblock} struct S { - constexpr S() = default; // ill-formed: implicit \tcode{S()} is not \tcode{constexpr} - S(int a = 0) = default; // ill-formed: default argument - void operator=(const S&) = default; // ill-formed: non-matching return type + constexpr S() = default; // error: implicit \tcode{S()} is not \tcode{constexpr} + S(int a = 0) = default; // error: default argument + void operator=(const S&) = default; // error: non-matching return type ~S() noexcept(false) = default; // OK, despite mismatched exception specification private: int i; @@ -6145,8 +6145,8 @@ void* operator new(std::size_t) = delete; void* operator new[](std::size_t) = delete; }; -sometype* p = new sometype; // error, deleted class \tcode{operator new} -sometype* q = new sometype[3]; // error, deleted class \tcode{operator new[]} +sometype* p = new sometype; // error: deleted class \tcode{operator new} +sometype* q = new sometype[3]; // error: deleted class \tcode{operator new[]} \end{codeblock} \end{example} @@ -6164,7 +6164,7 @@ ~moveonly() = default; }; moveonly* p; -moveonly q(*p); // error, deleted copy constructor +moveonly q(*p); // error: deleted copy constructor \end{codeblock} \end{example} @@ -6184,7 +6184,7 @@ struct sometype { sometype(); }; -sometype::sometype() = delete; // ill-formed; not first declaration +sometype::sometype() = delete; // error: not first declaration \end{codeblock} \end{example} \indextext{definition!function|)} @@ -6962,7 +6962,7 @@ enum class color { red, orange }; void f() { using enum fruit; // OK - using enum color; // ill-formed: \tcode{color::orange} and \tcode{fruit::orange} conflict + using enum color; // error: \tcode{color::orange} and \tcode{fruit::orange} conflict } \end{codeblock} \end{example} @@ -7443,7 +7443,7 @@ } } void f4() { - i = 5; // ill-formed; neither \tcode{i} is visible + i = 5; // error: neither \tcode{i} is visible } \end{codeblock} \end{example} @@ -7732,8 +7732,8 @@ template struct X { }; }; struct B : A { - using A::f; // ill-formed - using A::X; // ill-formed + using A::f; // error + using A::X; // error }; \end{codeblock} \end{example} @@ -7987,7 +7987,7 @@ using B1::B1; using B2::B2; }; -D1 d1(0); // ill-formed: ambiguous +D1 d1(0); // error: ambiguous struct D2 : B1, B2 { using B1::B1; @@ -8303,12 +8303,12 @@ extern "C" int f(); extern "C" int g() { return 1; } extern "C" int h(); - extern "C" int x(); // ill-formed: same name as global-space object \tcode{x} + extern "C" int x(); // error: same name as global-space object \tcode{x} } namespace B { extern "C" int f(); // \tcode{A::f} and \tcode{B::f} refer to the same function - extern "C" int g() { return 1; } // ill-formed, the function \tcode{g} with C language linkage has two definitions + extern "C" int g() { return 1; } // error: the function \tcode{g} with C language linkage has two definitions } int A::f() { return 98; } // definition for the function \tcode{f} with C language linkage @@ -8602,7 +8602,7 @@ struct S { int x; } s, *p = &s; // Translation unit \#2: -struct alignas(16) S; // error: definition of \tcode{S} lacks alignment, no diagnostic required +struct alignas(16) S; // ill-formed, no diagnostic required: definition of \tcode{S} lacks alignment extern S* p; \end{codeblock} \end{example} @@ -8823,7 +8823,7 @@ h(); case 4: // implementation may warn on fallthrough i(); - [[fallthrough]]; // ill-formed + [[fallthrough]]; // error } } \end{codeblock} diff --git a/source/exceptions.tex b/source/exceptions.tex index 11a83c3d1d..45673e2c6a 100644 --- a/source/exceptions.tex +++ b/source/exceptions.tex @@ -77,15 +77,15 @@ \begin{example} \begin{codeblock} void f() { - goto l1; // ill-formed - goto l2; // ill-formed + goto l1; // error + goto l2; // error try { goto l1; // OK - goto l2; // ill-formed + goto l2; // error l1: ; } catch (...) { l2: ; - goto l1; // ill-formed + goto l1; // error goto l2; // OK } } @@ -772,7 +772,7 @@ }; struct D: B { - void f(); // ill-formed + void f(); // error void g() noexcept; // OK void h() = delete; // OK }; diff --git a/source/expressions.tex b/source/expressions.tex index b4feebe681..b665ce025b 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -618,7 +618,7 @@ return [&](bool b) { return (b ? y : x).n; }; } auto g = f(); -int m = g(false); // undefined behavior due to access of \tcode{x.n} outside its lifetime +int m = g(false); // undefined behavior: access of \tcode{x.n} outside its lifetime int n = g(true); // OK, does not access \tcode{y.n} \end{codeblock} \end{example} @@ -1701,7 +1701,7 @@ NonLiteral(int n) : n(n) { } int n; }; -static_assert(ID(NonLiteral{3}).n == 3); // ill-formed +static_assert(ID(NonLiteral{3}).n == 3); // error \end{codeblock} \end{example} @@ -1728,7 +1728,7 @@ // in a constant expression. auto two = monoid(2); assert(two() == 2); // OK, not a constant expression. -static_assert(add(one)(one)() == two()); // ill-formed: \tcode{two()} is not a constant expression +static_assert(add(one)(one)() == two()); // error: \tcode{two()} is not a constant expression static_assert(add(one)(one)() == monoid(2)()); // OK \end{codeblock} \end{example} @@ -1870,7 +1870,7 @@ // No specialization of the function call operator template can be constexpr (due to the local static). auto NC = [](auto a) { static int s; return a; }; -static_assert(Fwd(NC,3) == 3); // ill-formed +static_assert(Fwd(NC,3) == 3); // error \end{codeblock} \end{example} @@ -2223,13 +2223,13 @@ \begin{codeblock} void f2() { int i = 1; - void g1(int = ([i]{ return i; })()); // ill-formed - void g2(int = ([i]{ return 0; })()); // ill-formed - void g3(int = ([=]{ return i; })()); // ill-formed + void g1(int = ([i]{ return i; })()); // error + void g2(int = ([i]{ return 0; })()); // error + void g3(int = ([=]{ return i; })()); // error void g4(int = ([=]{ return 0; })()); // OK void g5(int = ([]{ return sizeof i; })()); // OK void g6(int = ([x=1]{ return x; })()); // OK - void g7(int = ([x=i]{ return x; })()); // ill-formed + void g7(int = ([x=i]{ return x; })()); // error } \end{codeblock} \end{example} @@ -3487,7 +3487,7 @@ F f; A* ap = &f; // succeeds: finds unique \tcode{A} D* dp = dynamic_cast(ap); // fails: yields null; \tcode{f} has two \tcode{D} subobjects - E* ep = (E*)ap; // ill-formed: cast from virtual base + E* ep = (E*)ap; // error: cast from virtual base E* ep1 = dynamic_cast(ap); // succeeds } \end{codeblock} @@ -5199,7 +5199,7 @@ static void operator delete(void*, std::size_t); }; -S* p = new (0) S; // ill-formed: non-placement deallocation function matches +S* p = new (0) S; // error: non-placement deallocation function matches // placement allocation function \end{codeblock} @@ -5620,7 +5620,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 const object +cs.*pm = 88; // error: \tcode{cs} is a const object } \end{codeblock} \end{note} @@ -6977,7 +6977,7 @@ const int n = 0; [=] { constexpr int i = n; // OK, \tcode{n} is not odr-used here - constexpr int j = *&n; // ill-formed, \tcode{\&n} would be an odr-use of \tcode{n} + constexpr int j = *&n; // error: \tcode{\&n} would be an odr-use of \tcode{n} }; } \end{codeblock} @@ -7260,7 +7260,7 @@ consteval auto g() { return f; } consteval int h(int (*p)() = g()) { return p(); } constexpr int r = h(); // OK -constexpr auto e = g(); // ill-formed: a pointer to an immediate function is +constexpr auto e = g(); // error: a pointer to an immediate function is // not a permitted result of a constant expression \end{codeblock} \end{example} @@ -7315,7 +7315,7 @@ X x; // type \tcode{X} int y; const int a = std::is_constant_evaluated() ? y : 1; // dynamic initialization to 1 -double z[a]; // ill-formed: \tcode{a} is not usable +double z[a]; // error: \tcode{a} is not usable // in constant expressions const int b = std::is_constant_evaluated() ? 2 : y; // static initialization to 2 int c = y + (std::is_constant_evaluated() ? 2 : y); // dynamic initialization to \tcode{y+y} diff --git a/source/future.tex b/source/future.tex index 93db770ab1..ab4c28203e 100644 --- a/source/future.tex +++ b/source/future.tex @@ -31,7 +31,7 @@ enum E2 { f }; bool b = e <= 3.7; // deprecated int k = f - e; // deprecated -auto cmp = e <=> f; // ill-formed +auto cmp = e <=> f; // error \end{codeblock} \end{example} @@ -87,7 +87,7 @@ int arr2[5]; bool same = arr1 == arr2; // deprecated, same as \tcode{\&arr1[0] == \&arr2[0]}, // does not compare array contents -auto cmp = arr1 <=> arr2; // ill-formed +auto cmp = arr1 <=> arr2; // error \end{codeblock} \end{example} diff --git a/source/modules.tex b/source/modules.tex index acc442ccee..f19215233f 100644 --- a/source/modules.tex +++ b/source/modules.tex @@ -1048,6 +1048,6 @@ module B; import A; Y y; // OK, definition of \tcode{X} is reachable -X x; // ill-formed: \tcode{X} not visible to unqualified lookup +X x; // error: \tcode{X} not visible to unqualified lookup \end{codeblocktu} \end{example} diff --git a/source/overloading.tex b/source/overloading.tex index 0b4ef24e7f..5d50a29ab9 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -107,9 +107,9 @@ \begin{codeblock} class X { static void f(); - void f(); // ill-formed - void f() const; // ill-formed - void f() const volatile; // ill-formed + void f(); // error + void f() const; // error + void f() const volatile; // error void g(); void g() const; // OK: no static \tcode{g} void g() const volatile; // OK: no static \tcode{g} @@ -136,8 +136,7 @@ void h() const &; // OK void h() &&; // OK, all declarations have a ref-qualifier void i() &; - void i() const; // ill-formed, prior declaration of \tcode{i} - // has a ref-qualifier + void i() const; // error: prior declaration of \tcode{i} has a ref-qualifier }; \end{codeblock} \end{example} @@ -224,7 +223,7 @@ void h(int()); void h(int (*)()); // redeclaration of \tcode{h(int())} void h(int x()) { } // definition of \tcode{h(int())} -void h(int (*x)()) { } // ill-formed: redefinition of \tcode{h(int())} +void h(int (*x)()) { } // error: redefinition of \tcode{h(int())} \end{codeblock} \end{example} @@ -624,7 +623,7 @@ public: C(int); }; -T a = 1; // ill-formed: \tcode{T(C(1))} not tried +T a = 1; // error: no viable conversion (\tcode{T(C(1))} not considered) \end{codeblock} \end{example} @@ -983,8 +982,9 @@ String operator + (const String&, const String&); void f() { - const char* p= "one" + "two"; // ill-formed because neither operand has class or enumeration type - int I = 1 + 1; // always evaluates to \tcode{2} even if class or enumeration types exist + const char* p= "one" + "two"; // error: cannot add two pointers; overloaded \tcode{operator+} not considered + // because neither operand has class or enumeration type + int I = 1 + 1; // always evaluates to \tcode{2} even if class or enumeration types exist // that would perform the operation. } \end{codeblock} @@ -2346,7 +2346,7 @@ void f(A) { } void f(C) { } B b; -f(b); // ill-formed: ambiguous because there is a conversion \tcode{b} $\to$ \tcode{C} (via constructor) +f(b); // error: ambiguous because there is a conversion \tcode{b} $\to$ \tcode{C} (via constructor) // and an (ambiguous) conversion \tcode{b} $\to$ \tcode{A} (via constructor or conversion function) void f(B) { } f(b); // OK, unambiguous diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 321e357abb..bb0a415d1a 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -1086,7 +1086,7 @@ SDEF(foo); // replaced by \tcode{S foo;} SDEF(bar, 1, 2); // replaced by \tcode{S bar = \{ 1, 2 \};} -#define H1(X, ...) X __VA_OPT__(##) __VA_ARGS__ // ill-formed: \tcode{\#\#} may not appear at +#define H1(X, ...) X __VA_OPT__(##) __VA_ARGS__ // error: \tcode{\#\#} may not appear at // the beginning of a replacement list\iref{cpp.concat} #define H2(X, Y, ...) __VA_OPT__(X ## Y,) __VA_ARGS__ diff --git a/source/statements.tex b/source/statements.tex index b27eba98e0..f7a3c25e4b 100644 --- a/source/statements.tex +++ b/source/statements.tex @@ -970,7 +970,7 @@ \begin{codeblock} void f() { // ... - goto lx; // ill-formed: jump into scope of \tcode{a} + goto lx; // error: jump into scope of \tcode{a} // ... ly: X a = 1; @@ -1006,7 +1006,7 @@ \begin{example} \begin{codeblock} int foo(int i) { - static int s = foo(2*i); // recursive call - undefined + static int s = foo(2*i); // undefined behavior: recursive call return i+1; } \end{codeblock} diff --git a/source/templates.tex b/source/templates.tex index 508a76276a..ad90463fd3 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -786,9 +786,9 @@ template static X* adjust(); }; template void f(T* p) { - T* p1 = p->alloc<200>(); // ill-formed: \tcode{<} means less than + T* p1 = p->alloc<200>(); // error: \tcode{<} means less than T* p2 = p->template alloc<200>(); // OK: \tcode{<} starts template argument list - T::adjust<100>(); // ill-formed: \tcode{<} means less than + T::adjust<100>(); // error: \tcode{<} means less than T::template adjust<100>(); // OK: \tcode{<} starts template argument list } \end{codeblock} @@ -909,7 +909,7 @@ Ptr p; // error: constraints not satisfied template -struct S2 { Ptr x; }; // error, no diagnostic required +struct S2 { Ptr x; }; // ill-formed, no diagnostic required template struct S3 { Ptr x; }; // OK, satisfaction is not required @@ -918,7 +918,7 @@ template class X> struct S4 { - X x; // error, no diagnostic required + X x; // ill-formed, no diagnostic required }; template concept C2 = sizeof(T) == 1; @@ -1068,7 +1068,7 @@ struct S { @\commentellip@ }; }; -A b; // ill-formed: \tcode{A} has no access to \tcode{B::S} +A b; // error: \tcode{A} has no access to \tcode{B::S} \end{codeblock} \end{example} @@ -1580,7 +1580,7 @@ int i2 = f2(42); // OK, \tcode{!sad} atomic constraint expressions both come from \tcode{not_sad} template int f3(T) requires (!sad); -int i3 = f3(42); // error, associated constraints not satisfied due to substitution failure +int i3 = f3(42); // error: associated constraints not satisfied due to substitution failure template concept sad_nested_type = sad; template int f4(T) requires (!sad_nested_type); @@ -2201,7 +2201,7 @@ template void S::f() { } // OK: \grammarterm{template-head}{s} match template void S::g() { } // error: no matching declaration for \tcode{S} -template requires C // error (no diagnostic required): \grammarterm{template-head}{s} are +template requires C // ill-formed, no diagnostic required: \grammarterm{template-head}{s} are void S::h() { } // functionally equivalent but not equivalent template template @@ -3036,8 +3036,7 @@ // it is not a specialization of \tcode{A::B} template friend void A::f(); // does not grant friendship to \tcode{A::f()} // because its return type does not match - template friend void A::D::g(); // ill-formed: \tcode{A::D} does not end with - // a \grammarterm{simple-template-id} + template friend void A::D::g(); // error: \tcode{A::D} does not end with a \grammarterm{simple-template-id} template friend int *A::h(); // grants friendship to \tcode{A::h()} and \tcode{A::h()} template template // grants friendship to instantiations of \tcode{A::i()} and friend T A::i(); // to \tcode{A::i()}, and thereby to all specializations @@ -3474,7 +3473,7 @@ a0.f(); // OK, uses definition of primary template's member a2.g(); // OK, uses definition of partial specialization's member a2.h(); // OK, uses definition of explicit specialization's member - a2.f(); // ill-formed, no definition of \tcode{f} for \tcode{A}; the primary template is not used here + a2.f(); // error: no definition of \tcode{f} for \tcode{A}; the primary template is not used here } \end{codeblock} \end{example} @@ -3993,7 +3992,7 @@ \begin{codeblock} template using void_t = void; template void_t f(); -f(); // error, \tcode{int} does not have a nested type \tcode{foo} +f(); // error: \tcode{int} does not have a nested type \tcode{foo} \end{codeblock} \end{example} @@ -4134,10 +4133,10 @@ typedef typename T::A TA; TA* a5; // declare pointer to \tcode{T}'s \tcode{A} typename T::A* a6; // declare pointer to \tcode{T}'s \tcode{A} - T::A* a7; // \tcode{T::A} is not a type name: - // multiplication of \tcode{T::A} by \tcode{a7}; ill-formed, no visible declaration of \tcode{a7} - B* a8; // \tcode{B} is not a type name: - // multiplication of \tcode{B} by \tcode{a8}; ill-formed, no visible declarations of \tcode{B} and \tcode{a8} + T::A* a7; // error: no visible declaration of \tcode{a7} + // \tcode{T::A} is not a type name; multiplication of \tcode{T::A} by \tcode{a7} + B* a8; // error: no visible declarations of \tcode{B} and \tcode{a8} + // \tcode{B} is not a type name; multiplication of \tcode{B} by \tcode{a8} } }; \end{codeblock} @@ -4240,7 +4239,7 @@ \begin{example} \begin{codeblock} template T::R f(); // OK, return type of a function declaration at global scope -template void f(T::R); // ill-formed (no diagnostic required), attempt to declare +template void f(T::R); // ill-formed, no diagnostic required: attempt to declare // a \tcode{void} variable template template struct S { using Ptr = PtrTraits::Ptr; // OK, in a \grammarterm{defining-type-id} @@ -5736,7 +5735,7 @@ number a(3), b(4); a = gcd(a,b); // finds \tcode{gcd} because \tcode{number} is an associated class, // making \tcode{gcd} visible in its namespace (global scope) - b = gcd(3,4); // ill-formed; \tcode{gcd} is not visible + b = gcd(3,4); // error: \tcode{gcd} is not visible } \end{codeblock} \end{example} @@ -5876,7 +5875,7 @@ static T t; }; typedef int function(); -A a; // ill-formed: would declare \tcode{A::t} as a static member function +A a; // error: would declare \tcode{A::t} as a static member function \end{codeblock} \end{example} @@ -5997,7 +5996,7 @@ template friend int f(U) { return sizeof(T); } }; Friendly fc; -Friendly ff; // ill-formed: produces second definition of \tcode{f(U)} +Friendly ff; // error: produces second definition of \tcode{f(U)} \end{codeblock} \end{example} @@ -6216,7 +6215,7 @@ void g(A a, A b, A c) { f(a, b, c); // no default argument instantiation f(a, b); // default argument \tcode{z = zdef(T())} instantiated - f(a); // ill-formed; \tcode{ydef} is not declared + f(a); // error: \tcode{ydef} is not declared } \end{codeblock} \end{example} @@ -6780,7 +6779,7 @@ template<> enum class A::S : int { sint }; // OK template enum A::E : T { eT }; template enum class A::S : T { sT }; -template<> enum A::E : char { echar }; // ill-formed, \tcode{A::E} was instantiated +template<> enum A::E : char { echar }; // error: \tcode{A::E} was instantiated // when \tcode{A} was instantiated template<> enum class A::S : char { schar }; // OK \end{codeblock} @@ -6998,7 +6997,7 @@ template <> template <> template void A::B::mf1(T t) { } template template <> - void A::B::mf2() { } // ill-formed; \tcode{B} is specialized but + void A::B::mf2() { } // error: \tcode{B} is specialized but // its enclosing class template \tcode{A} is not \end{codeblock} \end{example} @@ -7147,9 +7146,9 @@ template X g(Y); void h() { int i = f(5.6); // \tcode{Y} deduced as \tcode{double} - int j = f(5.6); // ill-formed: \tcode{X} cannot be deduced + int j = f(5.6); // error: \tcode{X} cannot be deduced f(f); // \tcode{Y} for outer \tcode{f} deduced as \tcode{int (*)(bool)} - f(f); // ill-formed: \tcode{f} does not denote a single function template specialization + f(f); // error: \tcode{f} does not denote a single function template specialization int k = g(5.6); // \tcode{Y} deduced as double; \tcode{Z} deduced as an empty sequence f(g); // \tcode{Y} for outer \tcode{f} deduced as \tcode{int (*)(bool)}, // \tcode{Z} deduced as an empty sequence diff --git a/source/utilities.tex b/source/utilities.tex index f276e7f987..12ad2e7f1d 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -5597,8 +5597,7 @@ const any y(cat); // \tcode{const y} holds \tcode{string} assert(any_cast(y) == cat); -any_cast(y); // error; cannot - // \tcode{any_cast} away const +any_cast(y); // error: cannot \tcode{any_cast} away const \end{codeblock} \end{example} \end{itemdescr} @@ -20600,9 +20599,9 @@ struct err {}; std::string s0 = std::format("{}", 42); // OK, library-provided formatter -std::string s1 = std::format("{}", L"foo"); // ill-formed: disabled formatter +std::string s1 = std::format("{}", L"foo"); // error: disabled formatter std::string s2 = std::format("{}", red); // OK, user-provided formatter -std::string s3 = std::format("{}", err{}); // ill-formed: disabled formatter +std::string s3 = std::format("{}", err{}); // error: disabled formatter \end{codeblock} \end{example}