https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115844
Bug ID: 115844 Summary: [14 Regression] Invalid diagnostics for correctly-rejected non-consteval call in consteval function called in a regular lambda Product: gcc Version: 14.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ali.mpfard at gmail dot com Target Milestone: --- (Presumably post-<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107687>) Diagnostics are completely wrong about consteval-ness of surrounding context when an immediate function evaluation fails due to calling a non-consteval function. Furthermore, the actual cause is nowhere to be seen in the diagnostics. Reproducer (CE link: https://gcc.godbolt.org/z/hdjecKsEn) template<typename> void point_at_me(); template<typename T> consteval void point_at_that() { point_at_me<T>(); } int main() { auto x = 42; auto l = [&x] { x += 1; point_at_that<int>(); }; l(); } Diagnostics on trunk: repro.cpp: In function 'int main()': repro.cpp:16:6: error: call to consteval function 'l.main()::<lambda()>()' is not a constant expression 16 | l(); | ~^~ repro.cpp:16:6: in 'constexpr' expansion of 'l.main()::<lambda()>()' repro.cpp:12:11: error: the value of 'l' is not usable in a constant expression 12 | x += 1; | ~~^~~~ repro.cpp:11:10: note: 'l' was not declared 'constexpr' 11 | auto l = [&x] { | ^ repro.cpp:13:27: note: 'main()::<lambda()>' was promoted to an immediate function because its body contains an immediate-escalating expression 'point_at_that<int>()' 13 | point_at_that<int>(); | ~~~~~~~~~~~~~~~~~~^~ Diagnostics on 13.3 (expected): repro.cpp: In lambda function: repro.cpp:13:27: error: 'consteval void point_at_that() [with T = int]' called in a constant expression 13 | point_at_that<int>(); | ~~~~~~~~~~~~~~~~~~^~ repro.cpp:5:16: note: 'consteval void point_at_that() [with T = int]' is not usable as a 'constexpr' function because: 5 | consteval void point_at_that() { | ^~~~~~~~~~~~~ repro.cpp:6:19: error: call to non-'constexpr' function 'void point_at_me() [with <template-parameter-1-1> = int]' 6 | point_at_me<T>(); | ~~~~~~~~~~~~~~^~ repro.cpp:2:6: note: 'void point_at_me() [with <template-parameter-1-1> = int]' declared here 2 | void point_at_me(); | ^~~~~~~~~~~