// P2564R3 // { dg-do compile { target c++20 } } // Test default arguments. consteval int id (int i) { return i; } template constexpr int f1 (int i = id (42)) { return i; } int non_const; // { dg-message ".int non_const. is not const" } template constexpr int f2 (int i = id (non_const)) { return i; } constexpr int f3 (auto) { return f2(); // { dg-message "contains an immediate-escalating expression .id\\(non_const\\)." } } auto a = &f3; // { dg-error "taking address of an immediate function" } void g (int i) { f1 (42); f1 (i); f1 (); f2 (42); f2 (i); f2 (); // { dg-error "call to consteval function .id\\(non_const\\). is not a constant expression" } // { dg-error ".non_const. is not usable in a constant expression" "" { target *-*-* } .-1 } }