Title
Redefining names from base classes
Status
nad
Section
6.4.7 [basic.scope.class]
Submitter
Steve Clamage

Created on 1998-09-15.00:00:00 last changed 299 months ago

Messages

Date: 1999-04-15.00:00:00

Rationale (04/99): It is sufficiently clear that "name" includes qualified names and hence the usual lookup rules make this legal.

Date: 2022-02-18.07:47:23

Consider this code:

    struct Base {
        enum { a, b, c, next };
    };

    struct Derived : public Base {
        enum { d = Base::next, e, f, next };
    };

The idea is that the enumerator "next" in each class is the next available value for enumerators in further derived classes.

If we had written

    enum { d = next, e, f, next };

I think we would run afoul of 6.4.7 [basic.scope.class] :
A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S. No diagnostic is required for a violation of this rule.
But in the original code, we don't have an unqualified "next" that refers to anything but the current scope. I think the intent was to allow the code, but I don't find the wording clear on on that point.

Is there another section that makes it clear whether the original code is valid? Or am I being obtuse? Or should the quoted section say "An unqualified name N used in a class ..."?

Rationale (04/99): It is sufficiently clear that "name" includes qualified names and hence the usual lookup rules make this legal.

History
Date User Action Args
1999-09-14 00:00:00adminsetmessages: + msg186
1999-09-14 00:00:00adminsetstatus: drafting -> nad
1998-09-15 00:00:00admincreate