https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114311
Bug ID: 114311 Summary: wrong "error: ‘this’ is not a constant expression" with consteval member function Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: carlo at gcc dot gnu.org Target Milestone: --- The following snippet: ``` template<int Id> struct SymbolRef { }; struct Symbol { int const id_; consteval Symbol() : id_(1) { } template<int Id> consteval operator SymbolRef<Id>() const { return SymbolRef<id_>{}; } }; ``` fails with error: ``` source>: In member function 'consteval Symbol::operator SymbolRef<Id>() const': <source>:12:22: error: '*(const Symbol*)this' is not a constant expression 12 | return SymbolRef<id_>{}; | ^~~ <source>:12:22: note: in template argument for type 'int' ``` Not a regression. DOES compile with using `this->id_`.