Skip to content

[Clang] Unexpected Overloading of Static and Non-Static Member Functions #93456

@16bit-ykiko

Description

@16bit-ykiko

According to the C++ Standard, static and non-static member functions with the same parameter types cannot be overloaded. The following code should fail to compile.

struct X {
    void f() const;
    static void f();
};

It fails in clang 17, but succeeds in clang 18. And I find it is related to the declaration order. If swap the declaration order of the two functions

struct X {
    static void f();
    void f() const;
};

It fails as expected, please see Compiler Explorer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepts-invalidclang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions