https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101295
Bug ID: 101295 Summary: constexpr destructor: ''result_decl' not supported by dump_expr<expression error>' is not a constant expression Product: gcc Version: 11.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: markus.kuehni at triviso dot ch Target Milestone: --- Trying to conceptualize a constexpr capable, optimizer friendly linked list reference tracking smart pointer, I get this error: <source>: In function 'int main()': <source>:49:16: in 'constexpr' expansion of 'test()' <source>:49:16: in 'constexpr' expansion of '(&<anonymous>)->myptr<Obj>::~myptr()' <source>:49:16: error: ''result_decl' not supported by dump_expr<expression error>' is not a constant expression 49 | return test(); ... I'm not sure whether the code is standards compliant, but the error message is broken anyway, it seems. The same code works as I expect on clang, but creates an ICE on msvc. I tried to create a minimal example that still shows the intention of the code. https://godbolt.org/z/sod6oYE8T ``` // Minimized code of a linked list reference tracking smart pointer. template<typename T> struct myptr { private: T * p; myptr * next; public: constexpr myptr(T * p) noexcept : p(p), next(p ? p->first : nullptr) { if (p) { p->first = this; } } constexpr myptr(const myptr & other) noexcept : myptr(other.p) {} constexpr ~myptr() noexcept { if (p) { myptr ** pnext = &(p->first); while (*pnext != this) { pnext = &((*pnext)->next); } *pnext = next; next = nullptr; if (!p->first) { delete p; } p = nullptr; } } }; struct Obj { private: struct myptr<Obj> * first{}; friend struct myptr<Obj>; }; constexpr myptr<Obj> fun() { myptr<Obj> obj(new Obj); return obj; } // Force consteval to prove the myptr is constexpr capable. consteval int test() { fun(); return 42; } int main() { return test(); } ```