CWG Issue 139 (original) (raw)
This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 117a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2025-04-13
139. Error in friend lookup example
Section: 6.5.3 [basic.lookup.unqual]Status: CD1Submitter: Mike MillerDate: 14 Jul 1999
[Moved to DR at 10/01 meeting.]
The example in 6.5.3 [basic.lookup.unqual] paragraph 3 is incorrect:
typedef int f;
struct A {
friend void f(A &);
operator int();
void g(A a) {
f(a);
}
};
Regardless of the resolution of other issues concerning the lookup of names in friend declarations, this example is ill-formed (the function and the typedef cannot exist in the same scope).
One possible repair of the example would be to make fa class with a constructor taking either A or intas its parameter.
(See also issues95,136,138,143,165, and166.)
Proposed resolution (04/01):
- Change the example in 6.5.3 [basic.lookup.unqual] paragraph 3 to read:
typedef int f;
namespace N {
struct A {
friend int f(A &);
operator int();
void g(A a) {
int i = f(a);
// f is the typedef, not the friend function:
// equivalent to int(a)
}
};
} - Delete the sentence immediately following the example:
The expression f(a) is a _cast-expression_equivalent to int(a).