https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104620
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Reduced testcase for -std=c++23 consteval int foo (int x) { return x; } consteval int bar () { return 2; } template <typename T> constexpr int qux (int x) { int r = 0; if consteval { r += 2 * bar (); } else { r += foo (8 * x); // { dg-error "is not a constant expression" } } if ! consteval { r += foo (32 * x);// { dg-error "is not a constant expression" } } if consteval { r += 32 * bar (); } return r; } The intent of the testcase was to test whether we catch at least some of the non-dependent consteval calls already during template parsing and so regardless of whether we actually instantiate them or not. Worst case it will be diagnosed during instantiation, sure. But x is not type nor value dependent and neither is 8 * x nor 32 * x. And make_args_non_dependent calls build_non_dependent_arg which will not wrap say x or 8, but does wrap x * 8 even when both arguments have integral types. So, either build_non_dependent_arg should be made smarter and not wrap even simple arithmetics etc. where no C++ template-ish trees appear inside of it and everything is like in normal non-template-ish code, or we should reconsider the r12-7264 case because clearly often we can handle NON_DEPENDENT_EXPR just fine.