Title
Error in friend lookup example
Status
cd1
Section
6.5.3 [basic.lookup.unqual]
Submitter
Mike Miller

Created on 1999-07-14.00:00:00 last changed 161 months ago

Messages

Date: 2001-10-15.00:00:00

[Moved to DR at 10/01 meeting.]

Date: 2001-04-15.00:00:00

Proposed resolution (04/01):

  1. 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)
                }
            };
        }
    
  2. Delete the sentence immediately following the example:

    The expression f(a) is a cast-expression equivalent to int(a).
Date: 2001-05-20.00:00:00

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 f a class with a constructor taking either A or int as its parameter.

(See also issues 95, 136, 138, 143, 165, and 166.)

History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2003-04-25 00:00:00adminsetstatus: dr -> wp
2002-05-10 00:00:00adminsetmessages: + msg660
2001-11-09 00:00:00adminsetstatus: ready -> dr
2001-05-20 00:00:00adminsetmessages: + msg473
2001-05-20 00:00:00adminsetstatus: review -> ready
2000-11-18 00:00:00adminsetstatus: open -> review
1999-07-14 00:00:00admincreate