https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113713
Bug ID: 113713
Summary: static_assert result depends on optimization settings
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
This program
struct A{};
constexpr bool p(auto) { return false; }
constexpr bool f(auto v) { return p(v); }
constexpr bool g() { return f(A()); }
constexpr bool p(A) { return true; }
static_assert( f(A{}) );
The static_assert passes in GCC only with -O0 command line option, and it fails
with -O1 and higher optimization options, which looks wrong. Online demo:
https://godbolt.org/z/vWq8G7rn4
Related discussion: https://stackoverflow.com/q/77923182/7325599