[cfe-dev] Is this a clang bug? "Foo::Foo::bar"

Jonathan Sauer jonathan.sauer at gmx.de
Tue Jul 16 06:35:44 PDT 2013


Hello,

the following program compiles with clang r186311, and I'm not sure if this is a bug
or correct behavior:

struct Foo {
    void bar();
};


void Foo::Foo::Foo::Foo::Foo::Foo::bar()
{
}


According to §3.3.7p1 bullet 5 (basic.scope.class), the potential scope of a class
includes "the regions defined by its member definitions [...] including the member
function body and any portion of the declarator part of such definitions which follows
the declarator-id", and §3.4.3.1p1 (class.qual) states that "A class member can be
referred to using a qualified-id at any point in its potential scope" while "the name
[specified after the nested-name-specifier] shall represent one or more members of
that class or of one of its base classes."

However in the code above the member function "bar" is referred to using a qualified-id
in its declarator-id, which is not part of the class' potential scope, and "Foo" isn't
a base class of itself, so this shouldn't be allowed.

Still, I'm not sure if I got all the subtleties of C++'s name lookup rules right, so
I'd like to make sure if this is a bug in clang or merely the somewhat amusing result
of the way names in C++ can be specified.


With many thanks in advance,
Jonathan





More information about the cfe-dev mailing list