Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OK, error, ambiguous consistency of comments in examples. #971

Closed
wants to merge 9 commits into from
14 changes: 7 additions & 7 deletions source/access.tex
Original file line number Diff line number Diff line change
@@ -88,8 +88,8 @@
};

void f() {
A::BB x; // OK, typedef name \tcode{A::BB} is public
A::B y; // access error, \tcode{A::B} is private
A::BB x; // OK: typedef name \tcode{A::BB} is public
A::B y; // access error: \tcode{A::B} is private
}
\end{codeblock}
\end{note}
@@ -187,7 +187,7 @@
template <class U, class V = typename U::TT>
class D : public U { };

D <C<B> >* d; // access error, C::TT is protected
D <C<B> >* d; // access error: C::TT is protected
\end{codeblock}
\end{example}

@@ -657,7 +657,7 @@
};

class Y {
int v[X::a]; // OK, \tcode{Y} is a friend of \tcode{X}
int v[X::a]; // OK: \tcode{Y} is a friend of \tcode{X}
};

class Z {
@@ -842,13 +842,13 @@
class A {
friend class X; // OK, but \tcode{X} is a local class, not \tcode{::X}
friend class Y; // OK
friend class Z; // OK, introduces local class \tcode{Z}
friend void a(); // error, \tcode{::a} is not considered
friend class Z; // OK: introduces local class \tcode{Z}
friend void a(); // error: \tcode{::a} is not considered
friend void b(); // OK
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}
16 changes: 8 additions & 8 deletions source/basic.tex
Original file line number Diff line number Diff line change
@@ -914,7 +914,7 @@
class X {
char v[i]; // error: \tcode{i} refers to \tcode{::i}
// but when reevaluated is \tcode{X::i}
int f() { return sizeof(c); } // OK: \tcode{X::c}
int f() { return sizeof(c); } // OK: \tcode{X::c}
char c;
enum { i = 2 };
};
@@ -1753,7 +1753,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}
@@ -1949,8 +1949,8 @@
namespace C {
using namespace A;
using namespace B;
int i = C::x; // OK, \tcode{A::x} (of type \tcode{int} )
int j = C::y; // ambiguous, \tcode{A::y} or \tcode{B::y}
int i = C::x; // OK: \tcode{A::x} (of type \tcode{int} )
int j = C::y; // ambiguous: \tcode{A::y} or \tcode{B::y}
}
\end{codeblock}
\end{example}
@@ -1977,7 +1977,7 @@
}
using namespace B;
}
void A::f1(int){ } // ill-formed, \tcode{f1} is not a member of \tcode{A}
void A::f1(int){ } // ill-formed: \tcode{f1} is not a member of \tcode{A}
\end{codeblock}

\end{example} However, in such namespace member declarations, the
@@ -2000,7 +2000,7 @@

using namespace A;
using namespace C::D;
void B::f1(int){ } // OK, defines \tcode{A::B::f1(int)}
void B::f1(int){ } // OK: defines \tcode{A::B::f1(int)}
\end{codeblock}
\end{example}
\indextext{lookup!qualified~name|)}%
@@ -3325,7 +3325,7 @@
void B::mutate() {
new (this) D2; // reuses storage --- ends the lifetime of \tcode{*this}
f(); // undefined behavior
... = this; // OK, \tcode{this} points to valid memory
... = this; // OK: \tcode{this} points to valid memory
}

void g() {
@@ -3594,7 +3594,7 @@

X x;
void bar() {
xp = &x; // OK; type is ``pointer to \tcode{X}''
xp = &x; // OK: type is ``pointer to \tcode{X}''
arrp = &arr; // ill-formed: different types
xp++; // OK: \tcode{X} is complete
arrp++; // ill-formed: \tcode{UNKA} can't be completed
6 changes: 3 additions & 3 deletions source/classes.tex
Original file line number Diff line number Diff line change
@@ -316,7 +316,7 @@

\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.
@@ -781,7 +781,7 @@
union U { T1 t1; T2 t2; };
int f() {
U u = { { 1, 2 } }; // active member is \tcode{t1}
return u.t2.c; // OK, as if \tcode{u.t1.a} were nominated
return u.t2.c; // OK: as if \tcode{u.t1.a} were nominated
}
\end{codeblock}
\end{example}
@@ -1635,7 +1635,7 @@
struct X { const int a; int b; };
union Y { X x; int k; };
void g() {
Y y = { { 1, 2 } }; // OK, \tcode{y.x} is active union member (\ref{class.mem})
Y y = { { 1, 2 } }; // OK: \tcode{y.x} is active union member (\ref{class.mem})
int n = y.x.a;
y.k = 4; // OK: ends lifetime of \tcode{y.x}, \tcode{y.k} is active member of union
y.x.b = n; // undefined behavior: \tcode{y.x.b} modified outside its lifetime,
4 changes: 2 additions & 2 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
@@ -1578,12 +1578,12 @@
struct derived;
struct base {
friend struct derived;
private:
private:
base();
};
struct derived : base {};

derived d1{}; // Error. The code was well-formed before.
derived d1{}; // error: the code was well-formed before.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks wrong.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, it's not an error because it was OK before. After the change the comment makes no sense. The comment is saying "This is an error but it was OK before" and the current text says that much better.

derived d2; // still OK
\end{codeblock}

4 changes: 2 additions & 2 deletions source/conversions.tex
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@
}
auto g = f();
int m = g(false); // undefined behavior due to access of \tcode{x.n} outside its lifetime
int n = g(true); // OK, does not access \tcode{y.n}
int n = g(true); // OK: does not access \tcode{y.n}
\end{codeblock}
\end{example}
The result of the conversion is determined according to the
@@ -231,7 +231,7 @@
\begin{example}
\begin{codeblock}
struct X { int n; };
int k = X().n; // OK, \tcode{X()} prvalue is converted to xvalue
int k = X().n; // OK: \tcode{X()} prvalue is converted to xvalue
\end{codeblock}
\end{example}

46 changes: 23 additions & 23 deletions source/declarations.tex
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@

\begin{codeblock}
enum { }; // ill-formed
typedef class { }; // ill-formed
typedef class { }; // ill-formed
\end{codeblock}
\end{example}

@@ -1466,7 +1466,7 @@
-> decltype((h<T>())); // does not force completion of \tcode{A<T>}; \tcode{A<T>::\~{}A()} is
// not implicitly used within the context of this \grammarterm{decltype-specifier}
void r() {
q(42); // Error: deduction against \tcode{q} succeeds, so overload resolution
q(42); // error: deduction against \tcode{q} succeeds, so overload resolution
// selects the specialization ``\tcode{q(T) -> decltype((h<T>())) [with T=int]}''.
// The return type is \tcode{A<int>}, so a temporary is introduced and its
// destructor is used, so the program is ill-formed.
@@ -1678,7 +1678,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}

@@ -1690,14 +1690,14 @@
\tcode{return} statements.
\begin{example}
\begin{codeblock}
auto n = n; // error, \tcode{n}'s type is unknown
auto n = n; // error: \tcode{n}'s type is unknown
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}
else
return sum(i-1)+i; // OK, \tcode{sum}'s return type has been deduced
return sum(i-1)+i; // OK: \tcode{sum}'s return type has been deduced
}
\end{codeblock}
\end{example}
@@ -1729,19 +1729,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 <typename T> 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<> auto g(double); // OK, forward declaration with unknown return type
template char g(char); // error: no matching template
template<> auto g(double); // OK: forward declaration with unknown return type

template <class T> T g(T t) { return t; } // OK, not functionally equivalent to \#1
template char g(char); // OK, now there is a matching template
template <class T> 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 <typename T> struct A {
friend T frf(T);
@@ -1877,9 +1877,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<int>}
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}

@@ -1915,9 +1915,9 @@
container(Iter b, Iter e) -> container<typename std::iterator_traits<Iter>::value_type>;
std::vector<double> v = { /* ... */};

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 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
\end{codeblock}
\end{example}

@@ -3195,14 +3195,14 @@
}
using namespace A::B::C;
void f1() {
i = 5; // OK, \tcode{C::i} visible in \tcode{B} and hides \tcode{A::i}
i = 5; // OK: \tcode{C::i} visible in \tcode{B} and hides \tcode{A::i}
}
}
namespace D {
using namespace B;
using namespace C;
void f2() {
i = 5; // ambiguous, \tcode{B::C::i} or \tcode{A::i}?
i = 5; // ambiguous: \tcode{B::C::i} or \tcode{A::i}?
}
}
void f3() {
@@ -3349,7 +3349,7 @@
}

void f() {
d1++; // error: ambiguous \tcode{::d1} or \tcode{D::d1}?
d1++; // error: ambiguous: \tcode{::d1} or \tcode{D::d1}?
::d1++; // OK
D::d1++; // OK
d2++; // OK: \tcode{D::d2}
@@ -3580,7 +3580,7 @@

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}
extern "C" int g() { return 1; } // ill-formed: the function \tcode{g}
// with C language linkage has two definitions
}

@@ -3851,7 +3851,7 @@
struct alignas(8) S {};
struct alignas(1) U {
S s;
}; // Error: \tcode{U} specifies an alignment that is less strict than
}; // error: \tcode{U} specifies an alignment that is less strict than
// if the \tcode{alignas(1)} were omitted.
\end{codeblock}
\end{example}
Loading