https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79452

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to gnzlbg from comment #2)
>   if constexpr() {  // Error: expression missing in if condition

Oh, I didn't realise you meant without an expression. Yeah that doesn't work.

> > That sounds like a recipe for ODR violations.
> 
> Could you elaborate on why? Since the `constexpr_alias` will only be called
> during compile-time evaluation, it will never collide with the "run-time"
> alias (which is inline, since constexpr implies inline). Note that
> `foo_constexpr` is a completely different function than `foo`, so these two
> never collide either.

I wasn't replying to the part about function aliases, I was replying to the
part about having the built-in work even when used in a non-constexpr function.
It sounds like what you're suggesting would depend on optimisation levels,
rather than on the unambiguous semantics of whether something is actually a
constant-expression or not as defined by the C++ language. Maybe I
misunderstood what you mean by "some block inside that function is evaluated by
the constant expression evaluator". If you simply mean when the built-in
appears as part of a constant-expression that's fine.

Reply via email to