小编Jef*_*ett的帖子

Does this code result in a materialized base prvalue, and should it compile?

The following code compiles in gcc 9.1 godbolt but not clang 8 godbolt:

class A {
protected:
    ~A() = default;
};

class B final : public A {
};

int main() {
    auto b = B{};
}
Run Code Online (Sandbox Code Playgroud)

Clang's error:

<source>:10:16: error: temporary of type 'A' has protected destructor
    auto b = B{};
               ^
<source>:3:5: note: declared protected here
    ~A() = default;
    ^
Run Code Online (Sandbox Code Playgroud)

Which is correct and why?

c++ destructor language-lawyer compiler-generated c++17

8
推荐指数
1
解决办法
192
查看次数