Skip to content

C++ static constexpr class variables considered 'invalid' as template arguments #114076

@mld2443

Description

@mld2443

https://godbolt.org/z/WY54brjqY

struct A {
    static constexpr int VALUE = 42;
    template <int ARG>
    constexpr int bar() const {
        return ARG;
    }

    constexpr int foo() const {
        return this->template bar<this->VALUE>();
    }
};

static_assert(A{}.foo()==42);

This code compiles with every version of GCC I tried, but I cannot get it to compile with clang at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:gccDoes the clang frontend diverge from gcc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions