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

Eric Fiselier <eric at efcs dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eric at efcs dot ca

--- Comment #7 from Eric Fiselier <eric at efcs dot ca> ---
There are definitely opportunities for ODR violations here, or at least
something like them. Consider the following case:

template <class T>
constexpr bool foo(T) {
  if constexpr(__ctfe__)
    return true;
  else
    return false
}

static_assert(foo(0));
auto runtime = foo(0);

Both calls instantiate foo with the same template arguments, so they should
seemingly both get the same instantiation with the w/e value of `__ctfe__` was
when the implicit instantiations occurred. Therefore one of the two calls to
foo() will return the wrong answer.

This problem is made ever worse if `__builtin_constant_expression` allows you
to generate non-dependent compile-time expressions based on the function
arguments.

One solution would be to consider the instantiation of `foo` to be value
dependent on a "implicit template parameter" representing `__ctfe__`.

Reply via email to