|
318 | 318 | simply a single function \tcode{f()} twice. For the same reason,
|
319 | 319 | \begin{codeblock}
|
320 | 320 | struct S { int a; };
|
321 |
| -struct S { int a; }; // error, double definition |
| 321 | +struct S { int a; }; // error: double definition |
322 | 322 | \end{codeblock}
|
323 | 323 | is ill-formed because it defines \tcode{S} twice.
|
324 | 324 | \end{example}
|
|
2476 | 2476 | };
|
2477 | 2477 |
|
2478 | 2478 | 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) |
2480 | 2480 | int c = X(a); // OK: \tcode{a.operator X().operator int()}
|
2481 | 2481 | \end{codeblock}
|
2482 | 2482 | \end{example}
|
|
2499 | 2499 | };
|
2500 | 2500 |
|
2501 | 2501 | 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()} |
2503 | 2503 | }
|
2504 | 2504 | }
|
2505 | 2505 | \end{codeblock}
|
|
2642 | 2642 |
|
2643 | 2643 | void h(Z z) {
|
2644 | 2644 | 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 |
2646 | 2646 | Y y3 = (Y)z; // OK: cast notation
|
2647 | 2647 | }
|
2648 | 2648 |
|
|
3614 | 3614 | \begin{example}
|
3615 | 3615 | \begin{codeblock}
|
3616 | 3616 | class X { @\commentellip@ };
|
3617 |
| -class Y : public X, public X { @\commentellip@ }; // ill-formed |
| 3617 | +class Y : public X, public X { @\commentellip@ }; // error |
3618 | 3618 |
|
3619 | 3619 | \end{codeblock}
|
3620 | 3620 | \begin{codeblock}
|
|
3930 | 3930 | Derived* dp = &d;
|
3931 | 3931 | D* q = dp->vf4(); // calls \tcode{Derived::vf4()} and does not
|
3932 | 3932 | // convert the result to \tcode{B*}
|
3933 |
| - dp->vf2(); // ill-formed: argument mismatch |
| 3933 | + dp->vf2(); // error: argument mismatch |
3934 | 3934 | }
|
3935 | 3935 | \end{codeblock}
|
3936 | 3936 | \end{example}
|
|
3988 | 3988 | A* ap = b1p;
|
3989 | 3989 | D* dp = &d;
|
3990 | 3990 | ap->f(); // calls \tcode{D::B1::f}
|
3991 |
| - dp->f(); // ill-formed: ambiguous |
| 3991 | + dp->f(); // error: ambiguous |
3992 | 3992 | }
|
3993 | 3993 | \end{codeblock}
|
3994 | 3994 | In class \tcode{D} above there are two occurrences of class \tcode{A}
|
|
4014 | 4014 | void f();
|
4015 | 4015 | };
|
4016 | 4016 |
|
4017 |
| -struct Error : VB1, VB2 { // ill-formed |
| 4017 | +struct Error : VB1, VB2 { // error |
4018 | 4018 | };
|
4019 | 4019 |
|
4020 | 4020 | struct Okay : VB1, VB2 {
|
|
4129 | 4129 | \begin{example}
|
4130 | 4130 | \begin{codeblock}
|
4131 | 4131 | struct C {
|
4132 |
| - virtual void f() = 0 { }; // ill-formed |
| 4132 | + virtual void f() = 0 { }; // error |
4133 | 4133 | };
|
4134 | 4134 | \end{codeblock}
|
4135 | 4135 | \end{example}
|
|
4348 | 4348 | pd->v++; // OK: only one \tcode{v} (virtual)
|
4349 | 4349 | pd->s++; // OK: only one \tcode{s} (static)
|
4350 | 4350 | 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} |
4352 | 4352 | }
|
4353 | 4353 | \end{codeblock}
|
4354 | 4354 | \end{example}
|
|
4413 | 4413 | void g() {
|
4414 | 4414 | D d;
|
4415 | 4415 | 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}? |
4417 | 4417 | V* pv = &d; // OK: only one \tcode{V} subobject
|
4418 | 4418 | }
|
4419 | 4419 | \end{codeblock}
|
|
5272 | 5272 | friend void c(); // error
|
5273 | 5273 | };
|
5274 | 5274 | 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 |
5276 | 5276 | }
|
5277 | 5277 | \end{codeblock}
|
5278 | 5278 | \end{example}
|
|
5310 | 5310 | };
|
5311 | 5311 |
|
5312 | 5312 | 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 |
5315 | 5315 | p2->i = 3; // OK (access through a \tcode{D2})
|
5316 | 5316 | 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 |
5318 | 5318 | 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} |
5320 | 5320 | D2::j = 6; // OK (because refers to static member)
|
5321 | 5321 | }
|
5322 | 5322 |
|
5323 | 5323 | 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 |
5326 | 5326 | i = 3; // OK (access through \tcode{this})
|
5327 | 5327 | 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 |
5329 | 5329 | int B::* pmi_B2 = &D2::i; // OK
|
5330 | 5330 | j = 5; // OK (because \tcode{j} refers to static member)
|
5331 | 5331 | B::j = 6; // OK (because \tcode{B::j} refers to static member)
|
5332 | 5332 | }
|
5333 | 5333 |
|
5334 | 5334 | 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 |
5338 | 5338 | }
|
5339 | 5339 | \end{codeblock}
|
5340 | 5340 | \end{example}
|
|
5659 | 5659 | struct A { A(); };
|
5660 | 5660 | struct B: public virtual A { };
|
5661 | 5661 | struct C: public A, public B { C(); };
|
5662 |
| -C::C(): A() { } // ill-formed: which \tcode{A}? |
| 5662 | +C::C(): A() { } // error: which \tcode{A}? |
5663 | 5663 | \end{codeblock}
|
5664 | 5664 | \end{example}
|
5665 | 5665 |
|
|
6018 | 6018 | int j;
|
6019 | 6019 | public:
|
6020 | 6020 | 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 |
6022 | 6022 | j(f()) { } // well-defined: bases are all initialized
|
6023 | 6023 | };
|
6024 | 6024 |
|
|
6030 | 6030 | class D : public B, C {
|
6031 | 6031 | int i;
|
6032 | 6032 | 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 |
6034 | 6034 | i(f()) { } // well-defined: bases are all initialized
|
6035 | 6035 | };
|
6036 | 6036 | \end{codeblock}
|
|
6152 | 6152 | using V2::V2;
|
6153 | 6153 | };
|
6154 | 6154 |
|
6155 |
| -D1 d1(0); // ill-formed: ambiguous |
| 6155 | +D1 d1(0); // error: ambiguous |
6156 | 6156 | D2 d2(0); // OK: initializes virtual \tcode{B} base class, which initializes the \tcode{A} base class
|
6157 | 6157 | // then initializes the \tcode{V1} and \tcode{V2} base classes as if by a defaulted default constructor
|
6158 | 6158 |
|
|
6192 | 6192 |
|
6193 | 6193 | extern B bobj;
|
6194 | 6194 | 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 |
6197 | 6197 |
|
6198 |
| -A* pa = &bobj; // undefined, upcast to a base class type |
| 6198 | +A* pa = &bobj; // undefined behavior: upcast to a base class type |
6199 | 6199 | B bobj; // definition of \tcode{bobj}
|
6200 | 6200 |
|
6201 | 6201 | extern X xobj;
|
|
6284 | 6284 | struct X { X(A*); };
|
6285 | 6285 |
|
6286 | 6286 | 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*} |
6288 | 6288 | // but \tcode{D} is not constructed
|
6289 | 6289 |
|
6290 | 6290 | // ``\tcode{D((C*)this)}\!'' would be defined: \tcode{E*} $\rightarrow$ \tcode{C*} is defined because \tcode{E()} has started,
|
|
6342 | 6342 | f(); // calls \tcode{V::f}, not \tcode{A::f}
|
6343 | 6343 | g(); // calls \tcode{B::g}, not \tcode{D::g}
|
6344 | 6344 | 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} |
6346 | 6346 | }
|
6347 | 6347 | \end{codeblock}
|
6348 | 6348 | \end{example}
|
|
6419 | 6419 | typeid(*v); // well-defined: \tcode{*v} has type \tcode{V}, a base of \tcode{B} yields \tcode{type_info} for \tcode{B}
|
6420 | 6420 | typeid(*a); // undefined behavior: type \tcode{A} not a base of \tcode{B}
|
6421 | 6421 | 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} |
6423 | 6423 | }
|
6424 | 6424 | \end{codeblock}
|
6425 | 6425 | \end{example}
|
|
6962 | 6962 | void foo(int i) {
|
6963 | 6963 | new (ap) D1; // calls \tcode{B::operator new(std::size_t, Arena*)}
|
6964 | 6964 | 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 |
6966 | 6966 | }
|
6967 | 6967 | \end{codeblock}
|
6968 | 6968 | \end{example}
|
|
0 commit comments