https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101054
Bug ID: 101054 Summary: Compiler inconsistently gives error when constexpr class function is called from lambda Product: gcc Version: 9.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: peter.fletcher at bandicootimaging dot com.au Target Milestone: --- Created attachment 51004 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51004&action=edit Source code to generate bug and GCC version info g++ treats a class with a constexpr cast function inconsistently when passed and captured by a lambda, with one usage producing the error message "error: use of ‘this’ in a constant expression". The error occurs in g++ 9.4.0 with -std=c++14 but not with -std=c++17. Apparently this problem does not occur with Godbolt, but I cannot test this myself.