https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124085
Bug ID: 124085
Summary: Argument to __builtin_constant_p is evaluated in a
constant context
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tbaeder at redhat dot com
Target Milestone: ---
See https://godbolt.org/z/fW51YxMWv for an example.
constexpr int bcp() {
int n = 0;
__builtin_constant_p(++n);
return n;
}
static_assert(bcp() == 1, "");
The documentation states:
> The expression is not evaluated, side-effects are discarded.
I can imagine that this is simply a difference between the builtin being
evaluated in a constant and a non-constant context. If that is true, the
documentation should reflect that.