Skip to content

Commit 2094aa8

Browse files
jensmaurerzygoloid
authored andcommitted
[std] Harmonize comments indicating errors.
1 parent 2069ec6 commit 2094aa8

13 files changed

+151
-153
lines changed

source/basic.tex

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,10 @@
10121012
\begin{example}
10131013
\begin{codeblock}
10141014
if (int x = f()) {
1015-
int x; // ill-formed, redeclaration of \tcode{x}
1015+
int x; // error: redeclaration of \tcode{x}
10161016
}
10171017
else {
1018-
int x; // ill-formed, redeclaration of \tcode{x}
1018+
int x; // error: redeclaration of \tcode{x}
10191019
}
10201020
\end{codeblock}
10211021
\end{example}
@@ -1958,9 +1958,9 @@
19581958
}
19591959
void test() {
19601960
auto x = make(); // OK, \tcode{decltype(x)} is \tcode{R::X} in module \tcode{M}
1961-
R::f(x); // ill-formed: \tcode{R} and \tcode{R::f} are not visible here
1961+
R::f(x); // error: \tcode{R} and \tcode{R::f} are not visible here
19621962
f(x); // OK, calls \tcode{R::f} from interface of \tcode{M}
1963-
f(x, S::Z()); // ill-formed: \tcode{S::f} in module \tcode{M} not considered
1963+
f(x, S::Z()); // error: \tcode{S::f} in module \tcode{M} not considered
19641964
// even though \tcode{S} is an associated namespace
19651965
apply(x, S::Z()); // OK, \tcode{S::f} is visible in instantiation context, and
19661966
// \tcode{R::g} is visible even though it has internal linkage
@@ -1996,7 +1996,7 @@
19961996
int main() {
19971997
int A;
19981998
A::n = 42; // OK
1999-
A b; // ill-formed: \tcode{A} does not name a type
1999+
A b; // error: \tcode{A} does not name a type
20002000
}
20012001
\end{codeblock}
20022002
\end{example}
@@ -2022,7 +2022,7 @@
20222022
static const int number = 50;
20232023
static X arr[number];
20242024
};
2025-
X C::arr[number]; // ill-formed:
2025+
X C::arr[number]; // error:
20262026
// equivalent to \tcode{::X} \tcode{C::arr[C::number];}
20272027
// and not to \tcode{C::X} \tcode{C::arr[C::number];}
20282028
\end{codeblock}
@@ -2149,7 +2149,7 @@
21492149
B::B() { }
21502150

21512151
B::A ba; // object of type \tcode{A}
2152-
A::A a; // error, \tcode{A::A} is not a type name
2152+
A::A a; // error: \tcode{A::A} is not a type name
21532153
struct A::A a2; // object of type \tcode{A}
21542154
\end{codeblock}
21552155
\end{example}
@@ -2371,7 +2371,7 @@
23712371
}
23722372
using namespace B;
23732373
}
2374-
void A::f1(int){ } // ill-formed, \tcode{f1} is not a member of \tcode{A}
2374+
void A::f1(int){ } // error: \tcode{f1} is not a member of \tcode{A}
23752375
\end{codeblock}
23762376
\end{example}
23772377
However, in such namespace member declarations, the
@@ -3288,7 +3288,7 @@
32883288
pb->mutate();
32893289
*pb; // OK: \tcode{pb} points to valid memory
32903290
void* q = pb; // OK: \tcode{pb} points to valid memory
3291-
pb->f(); // undefined behavior, lifetime of \tcode{*pb} has ended
3291+
pb->f(); // undefined behavior: lifetime of \tcode{*pb} has ended
32923292
}
32933293
\end{codeblock}
32943294
\end{example}
@@ -4533,8 +4533,8 @@
45334533
UNKA** arrpp;
45344534

45354535
void foo() {
4536-
xp++; // ill-formed: \tcode{X} is incomplete
4537-
arrp++; // ill-formed: incomplete type
4536+
xp++; // error: \tcode{X} is incomplete
4537+
arrp++; // error: incomplete type
45384538
arrpp++; // OK: sizeof \tcode{UNKA*} is known
45394539
}
45404540

@@ -4544,9 +4544,9 @@
45444544
X x;
45454545
void bar() {
45464546
xp = &x; // OK; type is ``pointer to \tcode{X}''
4547-
arrp = &arr; // ill-formed: different types
4547+
arrp = &arr; // error: different types
45484548
xp++; // OK: \tcode{X} is complete
4549-
arrp++; // ill-formed: \tcode{UNKA} can't be completed
4549+
arrp++; // error: \tcode{UNKA} can't be completed
45504550
}
45514551
\end{codeblock}
45524552
\end{example}
@@ -5464,7 +5464,7 @@
54645464
i = 7, i++, i++; // \tcode{i} becomes \tcode{9}
54655465

54665466
i = i++ + 1; // the value of \tcode{i} is incremented
5467-
i = i++ + i; // the behavior is undefined
5467+
i = i++ + i; // undefined behavior
54685468
i = i + 1; // the value of \tcode{i} is incremented
54695469
}
54705470
\end{codeblock}

source/classes.tex

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@
318318
simply a single function \tcode{f()} twice. For the same reason,
319319
\begin{codeblock}
320320
struct S { int a; };
321-
struct S { int a; }; // error, double definition
321+
struct S { int a; }; // error: double definition
322322
\end{codeblock}
323323
is ill-formed because it defines \tcode{S} twice.
324324
\end{example}
@@ -2476,7 +2476,7 @@
24762476
};
24772477

24782478
Y a;
2479-
int b = a; // error, \tcode{a.operator X().operator int()} not tried
2479+
int b = a; // error: no viable conversion (\tcode{a.operator X().operator int()} not considered)
24802480
int c = X(a); // OK: \tcode{a.operator X().operator int()}
24812481
\end{codeblock}
24822482
\end{example}
@@ -2499,7 +2499,7 @@
24992499
};
25002500

25012501
void f(Y& a) {
2502-
if (a) { // ill-formed: \tcode{X::operator int()} or \tcode{Y::operator char()}
2502+
if (a) { // error: ambiguous between \tcode{X::operator int()} and \tcode{Y::operator char()}
25032503
}
25042504
}
25052505
\end{codeblock}
@@ -2642,7 +2642,7 @@
26422642

26432643
void h(Z z) {
26442644
Y y1(z); // OK: direct-initialization
2645-
Y y2 = z; // ill-formed: copy-initialization
2645+
Y y2 = z; // error: no conversion function candidate for copy-initialization
26462646
Y y3 = (Y)z; // OK: cast notation
26472647
}
26482648

@@ -3614,7 +3614,7 @@
36143614
\begin{example}
36153615
\begin{codeblock}
36163616
class X { @\commentellip@ };
3617-
class Y : public X, public X { @\commentellip@ }; // ill-formed
3617+
class Y : public X, public X { @\commentellip@ }; // error
36183618

36193619
\end{codeblock}
36203620
\begin{codeblock}
@@ -3930,7 +3930,7 @@
39303930
Derived* dp = &d;
39313931
D* q = dp->vf4(); // calls \tcode{Derived::vf4()} and does not
39323932
// convert the result to \tcode{B*}
3933-
dp->vf2(); // ill-formed: argument mismatch
3933+
dp->vf2(); // error: argument mismatch
39343934
}
39353935
\end{codeblock}
39363936
\end{example}
@@ -3988,7 +3988,7 @@
39883988
A* ap = b1p;
39893989
D* dp = &d;
39903990
ap->f(); // calls \tcode{D::B1::f}
3991-
dp->f(); // ill-formed: ambiguous
3991+
dp->f(); // error: ambiguous
39923992
}
39933993
\end{codeblock}
39943994
In class \tcode{D} above there are two occurrences of class \tcode{A}
@@ -4014,7 +4014,7 @@
40144014
void f();
40154015
};
40164016

4017-
struct Error : VB1, VB2 { // ill-formed
4017+
struct Error : VB1, VB2 { // error
40184018
};
40194019

40204020
struct Okay : VB1, VB2 {
@@ -4129,7 +4129,7 @@
41294129
\begin{example}
41304130
\begin{codeblock}
41314131
struct C {
4132-
virtual void f() = 0 { }; // ill-formed
4132+
virtual void f() = 0 { }; // error
41334133
};
41344134
\end{codeblock}
41354135
\end{example}
@@ -4348,7 +4348,7 @@
43484348
pd->v++; // OK: only one \tcode{v} (virtual)
43494349
pd->s++; // OK: only one \tcode{s} (static)
43504350
int i = pd->e; // OK: only one \tcode{e} (enumerator)
4351-
pd->a++; // error, ambiguous: two \tcode{a}{s} in \tcode{D}
4351+
pd->a++; // error: ambiguous: two \tcode{a}{s} in \tcode{D}
43524352
}
43534353
\end{codeblock}
43544354
\end{example}
@@ -4413,7 +4413,7 @@
44134413
void g() {
44144414
D d;
44154415
B* pb = &d;
4416-
A* pa = &d; // error, ambiguous: \tcode{C}'s \tcode{A} or \tcode{B}'s \tcode{A}?
4416+
A* pa = &d; // error: ambiguous: \tcode{C}'s \tcode{A} or \tcode{B}'s \tcode{A}?
44174417
V* pv = &d; // OK: only one \tcode{V} subobject
44184418
}
44194419
\end{codeblock}
@@ -5272,7 +5272,7 @@
52725272
friend void c(); // error
52735273
};
52745274
X* px; // OK, but \tcode{::X} is found
5275-
Z* pz; // error, no \tcode{Z} is found
5275+
Z* pz; // error: no \tcode{Z} is found
52765276
}
52775277
\end{codeblock}
52785278
\end{example}
@@ -5310,31 +5310,31 @@
53105310
};
53115311

53125312
void fr(B* pb, D1* p1, D2* p2) {
5313-
pb->i = 1; // ill-formed
5314-
p1->i = 2; // ill-formed
5313+
pb->i = 1; // error
5314+
p1->i = 2; // error
53155315
p2->i = 3; // OK (access through a \tcode{D2})
53165316
p2->B::i = 4; // OK (access through a \tcode{D2}, even though naming class is \tcode{B})
5317-
int B::* pmi_B = &B::i; // ill-formed
5317+
int B::* pmi_B = &B::i; // error
53185318
int B::* pmi_B2 = &D2::i; // OK (type of \tcode{\&D2::i} is \tcode{int B::*})
5319-
B::j = 5; // ill-formed (not a friend of naming class \tcode{B})
5319+
B::j = 5; // error: not a friend of naming class \tcode{B}
53205320
D2::j = 6; // OK (because refers to static member)
53215321
}
53225322

53235323
void D2::mem(B* pb, D1* p1) {
5324-
pb->i = 1; // ill-formed
5325-
p1->i = 2; // ill-formed
5324+
pb->i = 1; // error
5325+
p1->i = 2; // error
53265326
i = 3; // OK (access through \tcode{this})
53275327
B::i = 4; // OK (access through \tcode{this}, qualification ignored)
5328-
int B::* pmi_B = &B::i; // ill-formed
5328+
int B::* pmi_B = &B::i; // error
53295329
int B::* pmi_B2 = &D2::i; // OK
53305330
j = 5; // OK (because \tcode{j} refers to static member)
53315331
B::j = 6; // OK (because \tcode{B::j} refers to static member)
53325332
}
53335333

53345334
void g(B* pb, D1* p1, D2* p2) {
5335-
pb->i = 1; // ill-formed
5336-
p1->i = 2; // ill-formed
5337-
p2->i = 3; // ill-formed
5335+
pb->i = 1; // error
5336+
p1->i = 2; // error
5337+
p2->i = 3; // error
53385338
}
53395339
\end{codeblock}
53405340
\end{example}
@@ -5659,7 +5659,7 @@
56595659
struct A { A(); };
56605660
struct B: public virtual A { };
56615661
struct C: public A, public B { C(); };
5662-
C::C(): A() { } // ill-formed: which \tcode{A}?
5662+
C::C(): A() { } // error: which \tcode{A}?
56635663
\end{codeblock}
56645664
\end{example}
56655665

@@ -6018,7 +6018,7 @@
60186018
int j;
60196019
public:
60206020
int f();
6021-
B() : A(f()), // undefined: calls member function but base \tcode{A} not yet initialized
6021+
B() : A(f()), // undefined behavior: calls member function but base \tcode{A} not yet initialized
60226022
j(f()) { } // well-defined: bases are all initialized
60236023
};
60246024

@@ -6030,7 +6030,7 @@
60306030
class D : public B, C {
60316031
int i;
60326032
public:
6033-
D() : C(f()), // undefined: calls member function but base \tcode{C} not yet initialized
6033+
D() : C(f()), // undefined behavior: calls member function but base \tcode{C} not yet initialized
60346034
i(f()) { } // well-defined: bases are all initialized
60356035
};
60366036
\end{codeblock}
@@ -6152,7 +6152,7 @@
61526152
using V2::V2;
61536153
};
61546154

6155-
D1 d1(0); // ill-formed: ambiguous
6155+
D1 d1(0); // error: ambiguous
61566156
D2 d2(0); // OK: initializes virtual \tcode{B} base class, which initializes the \tcode{A} base class
61576157
// then initializes the \tcode{V1} and \tcode{V2} base classes as if by a defaulted default constructor
61586158

@@ -6192,10 +6192,10 @@
61926192

61936193
extern B bobj;
61946194
B* pb = &bobj; // OK
6195-
int* p1 = &bobj.a; // undefined, refers to base class member
6196-
int* p2 = &bobj.y.i; // undefined, refers to member's member
6195+
int* p1 = &bobj.a; // undefined behavior: refers to base class member
6196+
int* p2 = &bobj.y.i; // undefined behavior: refers to member's member
61976197

6198-
A* pa = &bobj; // undefined, upcast to a base class type
6198+
A* pa = &bobj; // undefined behavior: upcast to a base class type
61996199
B bobj; // definition of \tcode{bobj}
62006200

62016201
extern X xobj;
@@ -6284,7 +6284,7 @@
62846284
struct X { X(A*); };
62856285

62866286
struct E : C, D, X {
6287-
E() : D(this), // undefined: upcast from \tcode{E*} to \tcode{A*} might use path \tcode{E*} $\rightarrow$ \tcode{D*} $\rightarrow$ \tcode{A*}
6287+
E() : D(this), // undefined behavior: upcast from \tcode{E*} to \tcode{A*} might use path \tcode{E*} $\rightarrow$ \tcode{D*} $\rightarrow$ \tcode{A*}
62886288
// but \tcode{D} is not constructed
62896289

62906290
// ``\tcode{D((C*)this)}\!'' would be defined: \tcode{E*} $\rightarrow$ \tcode{C*} is defined because \tcode{E()} has started,
@@ -6342,7 +6342,7 @@
63426342
f(); // calls \tcode{V::f}, not \tcode{A::f}
63436343
g(); // calls \tcode{B::g}, not \tcode{D::g}
63446344
v->g(); // \tcode{v} is base of \tcode{B}, the call is well-defined, calls \tcode{B::g}
6345-
a->f(); // undefined behavior, \tcode{a}'s type not a base of \tcode{B}
6345+
a->f(); // undefined behavior: \tcode{a}'s type not a base of \tcode{B}
63466346
}
63476347
\end{codeblock}
63486348
\end{example}
@@ -6419,7 +6419,7 @@
64196419
typeid(*v); // well-defined: \tcode{*v} has type \tcode{V}, a base of \tcode{B} yields \tcode{type_info} for \tcode{B}
64206420
typeid(*a); // undefined behavior: type \tcode{A} not a base of \tcode{B}
64216421
dynamic_cast<B*>(v); // well-defined: \tcode{v} of type \tcode{V*}, \tcode{V} base of \tcode{B} results in \tcode{B*}
6422-
dynamic_cast<B*>(a); // undefined behavior, \tcode{a} has type \tcode{A*}, \tcode{A} not a base of \tcode{B}
6422+
dynamic_cast<B*>(a); // undefined behavior: \tcode{a} has type \tcode{A*}, \tcode{A} not a base of \tcode{B}
64236423
}
64246424
\end{codeblock}
64256425
\end{example}
@@ -6962,7 +6962,7 @@
69626962
void foo(int i) {
69636963
new (ap) D1; // calls \tcode{B::operator new(std::size_t, Arena*)}
69646964
new D1[i]; // calls \tcode{::operator new[](std::size_t)}
6965-
new D1; // ill-formed: \tcode{::operator new(std::size_t)} hidden
6965+
new D1; // error: \tcode{::operator new(std::size_t)} hidden
69666966
}
69676967
\end{codeblock}
69686968
\end{example}

source/compatibility.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,7 @@
21182118
int g() { return f(); }
21192119

21202120
// Translation unit 2
2121-
int f(int a = 76) { return a; } // ill-formed (no diagnostic required); previously well-formed
2121+
int f(int a = 76) { return a; } // ill-formed, no diagnostic required; previously well-formed
21222122
int g();
21232123
int main() { return g(); } // used to return 42
21242124
\end{codeblock}

0 commit comments

Comments
 (0)