https://bugs.llvm.org/show_bug.cgi?id=49410

            Bug ID: 49410
           Summary: constexpr static data member template cause an error:
                    static data member 'v' already has an initializer
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++14
          Assignee: unassignedclangb...@nondot.org
          Reporter: danny321974...@gmail.com
                CC: blitzrak...@gmail.com, erik.pilking...@gmail.com,
                    llvm-bugs@lists.llvm.org, richard-l...@metafoo.co.uk

When compile the constexpr variable template below with option -std=c++14

struct A {
    template <typename T>
    static constexpr T v{};
};
template <typename T>
constexpr T A::v;

int main()
{
    auto ptr1 = &A::v<int>;
    auto ptr2 = &A::v<int>;  // no error if remove this line
}


generates the error below:

clang_cxx14.cpp:3:25: error: static data member 'v' already has an initializer
    static constexpr T v{};
                        ^
clang_cxx14.cpp:10:21: note: in instantiation of static data member 'A::v<int>'
requested here
    auto ptr1 = &A::v<int>;
                    ^
clang_cxx14.cpp:3:25: note: previous initialization is here
    static constexpr T v{};
                        ^
1 error generated.

No error in -std=c++17 or above

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to