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

--- Comment #2 from Eric Fiselier <eric at efcs dot ca> ---
This is a bug according to [expr.const]p2 which states:

> An expression e is a core constant expression unless the evaluation of e, 
> following the rules of the abstract machine, would evaluate one of the 
> following expressions:
> [...]

The key phrase being "would evaluate one of". The example never evaluates a
non-constant expression. GCC correctly accepts the control flow:

template <class T>
constexpr int foo() {
    if (sizeof(T))
        return 1;
    else
      assert(false && "BOOM!");
}

template <class T>
constexpr int bar() { return sizeof(T) ? 1 : throw 42; }

static_assert(foo() && bar());

In all both cases the unevaluated expressions do not cause constant evaluation
to fail.


[1] http://eel.is/c++draft/expr.const#2

Reply via email to