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

--- Comment #3 from Eric Fiselier <eric at efcs dot ca> ---
The `if (1)` isn't essential either.

void fail();

template <class T>
constexpr int foo() {
    if (sizeof(T))
        return 1;
    fail();
}

constexpr int x = foo<int>();

It seems to have something to do with whether the initial `if` statement is
fully covered, regardless of what's actually evaluated. (Note that the branches
of the initial `if` are evaluated, or not evaluated, correctly).

int fail();

template <class T>
constexpr int foo() {
    if (sizeof(T))
        return 1;
    else if (fail())
      fail(); // OK
   // Fallthrough is also OK
}

constexpr int x = foo<int>();

Reply via email to