https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113713
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2024-02-02 Status|UNCONFIRMED |NEW --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Confirmed, this is a constexpr issue in both clang and GCC (unless there is some unspecified behavior I don't know of). Take: ``` #if defined(CE) #define CONSTEXPR constexpr #else #define CONSTEXPR #endif struct A{}; template<class T> CONSTEXPR bool p(T) { return false; } template<class T> CONSTEXPR bool f(T v) { return p(v); } CONSTEXPR bool g() { return f(A()); } CONSTEXPR bool p(A) { return true; } int main() { A a; if (!f(a)) __builtin_abort(); } ``` Without CE being defined, this works at all optimizations level. With CE being defined this works at -O0 only (like there is some [incorrect?] caching going on at -O1 and above and clang is doing the caching at all levels).