https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104266
Bug ID: 104266
Summary: Temporaries with protected destructor are erroneously
permitted
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
This is invalid code currently accepted by GCC:
```
struct A {
protected:
~A() { }
};
struct B : A {};
int main() {
B b{};
}
```
but rejected in Clang and MSVC, because `B b{}` during aggregate initialization
implicitly creates a temporary `A{}`, which is not allowed in the context.
Demo: https://gcc.godbolt.org/z/Yehch5PzK