Skip to content

Commit 493be8a

Browse files
committed
[std] Harmonize comments indicating errors.
1 parent 4c6f1e8 commit 493be8a

13 files changed

+149
-151
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}
@@ -2477,7 +2477,7 @@
24772477
};
24782478

24792479
Y a;
2480-
int b = a; // error, \tcode{a.operator X().operator int()} not tried
2480+
int b = a; // error: \tcode{a.operator X().operator int()} not tried
24812481
int c = X(a); // OK: \tcode{a.operator X().operator int()}
24822482
\end{codeblock}
24832483
\end{example}
@@ -2500,7 +2500,7 @@
25002500
};
25012501

25022502
void f(Y& a) {
2503-
if (a) { // ill-formed: \tcode{X::operator int()} or \tcode{Y::operator char()}
2503+
if (a) { // error: \tcode{X::operator int()} or \tcode{Y::operator char()}
25042504
}
25052505
}
25062506
\end{codeblock}
@@ -2643,7 +2643,7 @@
26432643

26442644
void h(Z z) {
26452645
Y y1(z); // OK: direct-initialization
2646-
Y y2 = z; // ill-formed: copy-initialization
2646+
Y y2 = z; // error: copy-initialization
26472647
Y y3 = (Y)z; // OK: cast notation
26482648
}
26492649

@@ -3615,7 +3615,7 @@
36153615
\begin{example}
36163616
\begin{codeblock}
36173617
class X { @\commentellip@ };
3618-
class Y : public X, public X { @\commentellip@ }; // ill-formed
3618+
class Y : public X, public X { @\commentellip@ }; // error
36193619

36203620
\end{codeblock}
36213621
\begin{codeblock}
@@ -3931,7 +3931,7 @@
39313931
Derived* dp = &d;
39323932
D* q = dp->vf4(); // calls \tcode{Derived::vf4()} and does not
39333933
// convert the result to \tcode{B*}
3934-
dp->vf2(); // ill-formed: argument mismatch
3934+
dp->vf2(); // error: argument mismatch
39353935
}
39363936
\end{codeblock}
39373937
\end{example}
@@ -3989,7 +3989,7 @@
39893989
A* ap = b1p;
39903990
D* dp = &d;
39913991
ap->f(); // calls \tcode{D::B1::f}
3992-
dp->f(); // ill-formed: ambiguous
3992+
dp->f(); // error: ambiguous
39933993
}
39943994
\end{codeblock}
39953995
In class \tcode{D} above there are two occurrences of class \tcode{A}
@@ -4015,7 +4015,7 @@
40154015
void f();
40164016
};
40174017

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

40214021
struct Okay : VB1, VB2 {
@@ -4130,7 +4130,7 @@
41304130
\begin{example}
41314131
\begin{codeblock}
41324132
struct C {
4133-
virtual void f() = 0 { }; // ill-formed
4133+
virtual void f() = 0 { }; // error
41344134
};
41354135
\end{codeblock}
41364136
\end{example}
@@ -4349,7 +4349,7 @@
43494349
pd->v++; // OK: only one \tcode{v} (virtual)
43504350
pd->s++; // OK: only one \tcode{s} (static)
43514351
int i = pd->e; // OK: only one \tcode{e} (enumerator)
4352-
pd->a++; // error, ambiguous: two \tcode{a}{s} in \tcode{D}
4352+
pd->a++; // error: ambiguous: two \tcode{a}{s} in \tcode{D}
43534353
}
43544354
\end{codeblock}
43554355
\end{example}
@@ -4414,7 +4414,7 @@
44144414
void g() {
44154415
D d;
44164416
B* pb = &d;
4417-
A* pa = &d; // error, ambiguous: \tcode{C}'s \tcode{A} or \tcode{B}'s \tcode{A}?
4417+
A* pa = &d; // error: ambiguous: \tcode{C}'s \tcode{A} or \tcode{B}'s \tcode{A}?
44184418
V* pv = &d; // OK: only one \tcode{V} subobject
44194419
}
44204420
\end{codeblock}
@@ -5273,7 +5273,7 @@
52735273
friend void c(); // error
52745274
};
52755275
X* px; // OK, but \tcode{::X} is found
5276-
Z* pz; // error, no \tcode{Z} is found
5276+
Z* pz; // error: no \tcode{Z} is found
52775277
}
52785278
\end{codeblock}
52795279
\end{example}
@@ -5311,31 +5311,31 @@
53115311
};
53125312

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

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

53355335
void g(B* pb, D1* p1, D2* p2) {
5336-
pb->i = 1; // ill-formed
5337-
p1->i = 2; // ill-formed
5338-
p2->i = 3; // ill-formed
5336+
pb->i = 1; // error
5337+
p1->i = 2; // error
5338+
p2->i = 3; // error
53395339
}
53405340
\end{codeblock}
53415341
\end{example}
@@ -5660,7 +5660,7 @@
56605660
struct A { A(); };
56615661
struct B: public virtual A { };
56625662
struct C: public A, public B { C(); };
5663-
C::C(): A() { } // ill-formed: which \tcode{A}?
5663+
C::C(): A() { } // error: which \tcode{A}?
56645664
\end{codeblock}
56655665
\end{example}
56665666

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

@@ -6031,7 +6031,7 @@
60316031
class D : public B, C {
60326032
int i;
60336033
public:
6034-
D() : C(f()), // undefined: calls member function but base \tcode{C} not yet initialized
6034+
D() : C(f()), // undefined behavior: calls member function but base \tcode{C} not yet initialized
60356035
i(f()) { } // well-defined: bases are all initialized
60366036
};
60376037
\end{codeblock}
@@ -6153,7 +6153,7 @@
61536153
using V2::V2;
61546154
};
61556155

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

@@ -6193,10 +6193,10 @@
61936193

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

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

62026202
extern X xobj;
@@ -6285,7 +6285,7 @@
62856285
struct X { X(A*); };
62866286

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

62916291
// ``\tcode{D((C*)this)}\!'' would be defined: \tcode{E*} $\rightarrow$ \tcode{C*} is defined because \tcode{E()} has started,
@@ -6343,7 +6343,7 @@
63436343
f(); // calls \tcode{V::f}, not \tcode{A::f}
63446344
g(); // calls \tcode{B::g}, not \tcode{D::g}
63456345
v->g(); // \tcode{v} is base of \tcode{B}, the call is well-defined, calls \tcode{B::g}
6346-
a->f(); // undefined behavior, \tcode{a}'s type not a base of \tcode{B}
6346+
a->f(); // undefined behavior: \tcode{a}'s type not a base of \tcode{B}
63476347
}
63486348
\end{codeblock}
63496349
\end{example}
@@ -6420,7 +6420,7 @@
64206420
typeid(*v); // well-defined: \tcode{*v} has type \tcode{V}, a base of \tcode{B} yields \tcode{type_info} for \tcode{B}
64216421
typeid(*a); // undefined behavior: type \tcode{A} not a base of \tcode{B}
64226422
dynamic_cast<B*>(v); // well-defined: \tcode{v} of type \tcode{V*}, \tcode{V} base of \tcode{B} results in \tcode{B*}
6423-
dynamic_cast<B*>(a); // undefined behavior, \tcode{a} has type \tcode{A*}, \tcode{A} not a base of \tcode{B}
6423+
dynamic_cast<B*>(a); // undefined behavior: \tcode{a} has type \tcode{A*}, \tcode{A} not a base of \tcode{B}
64246424
}
64256425
\end{codeblock}
64266426
\end{example}
@@ -6963,7 +6963,7 @@
69636963
void foo(int i) {
69646964
new (ap) D1; // calls \tcode{B::operator new(std::size_t, Arena*)}
69656965
new D1[i]; // calls \tcode{::operator new[](std::size_t)}
6966-
new D1; // ill-formed: \tcode{::operator new(std::size_t)} hidden
6966+
new D1; // error: \tcode{::operator new(std::size_t)} hidden
69676967
}
69686968
\end{codeblock}
69696969
\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)