Clang/LLVM 9 和 10 SIGSEGV 用于内联静态 class 成员。漏洞?

Clang/LLVM 9 and 10 SIGSEGV for inline static class members. Bug?

在 Clang 中使用 inline static class 成员时,当成员是另一个 class/struct 时,我会出现意外行为: https://godbolt.org/z/mbH6k7

// std=c++17
#include <iostream>

struct A {
    double a = 42;
    A() { std::cout << "A()" << std::endl; }
};

inline static A a{}; // No problem

namespace N {
    inline static A a{}; // No problem
}

struct B {
    B() { std::cout << "B()" << std::endl; }
    inline static double d; // No problem with built-in types
    A& a1 = N::a; // No problem
    inline static A a2 = N::a; // No problem
    inline static A a3{}; // <-- Problem here!
};

B b1;
inline static B b2;

int main() {
    return 0;
}

预期输出,适用于 Clang 8.0.0、gcc、msvc:

A()
A()
A()
B()
B()

Clang 9.0.0 及更高版本的实际输出:139 (SIGSEGV)

这是一个错误,还是我遗漏了什么?

这对我来说听起来像是一个非常简单的错误:

[class.static.data]

An inline static data member may be defined in the class definition and may specify a brace-or-equal-initializer.

你的代码符合这个:

struct B {
    // ...
    inline static A a3{};
};