C++ PATCH for c++/87567, constexpr rejects call to non-constexpr function

Jason Merrill jason@redhat.com
Wed Oct 10 20:55:00 GMT 2018


On Wed, Oct 10, 2018 at 11:58 AM Marek Polacek <polacek@redhat.com> wrote:
>
> In this testcase, the call to f() can never be a constant expression, but
> that's not a problem because it is never reached.  We handle a similar scenario
> for IF_STMT, so we can just do the same.  The RANGE_FOR_STMT case seems to
> never be reached in the whole testsuite, so I didn't change that.

That seems like a hole in the testsuite.  How about this?

constexpr int
fn3()
{
  struct empty_range {
    constexpr int* begin() { return 0; }
    constexpr int* end() { return 0; }
  } e;
  for (auto x : e)
    f();
  return 0;
}

The patch is OK; you can address fn3 in a follow-up patch.

Jason



More information about the Gcc-patches mailing list