https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97664
Bug ID: 97664 Summary: constexpr evaluation incorrectly accepts non-constant destruction Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ldalessandro at gmail dot com Target Milestone: --- This one involves some language-lawyering, which is not my forte. While developing a constexpr, array-based vector that supports non-default constructible types, I have run into the following inconsistency between clang and gcc. https://godbolt.org/z/PYdq5P ``` #include <memory> struct Foo { mutable int n = 0; }; union U { Foo foo; constexpr U() {} }; struct cvector { U storage[1]; constexpr cvector() { std::construct_at(&storage[0].foo); } constexpr ~cvector() { std::destroy_at(&storage[0].foo); } }; constexpr cvector v; ``` After some slack discussion that I didn't entirely follow, it seems that http://eel.is/c++draft/expr.const#7.2 combined with http://eel.is/c++draft/expr.const#6.2 may exclude the constexpr use of destroy_at of an instance of a class with mutable members. I am not confident with this analysis, nor am I confident that this is desirable behavior, but am reporting it for consideration.