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

            Bug ID: 69324
           Summary: non-constexpr function cannot be called in a constexpr
                    initializer even if the full-expression is a constexpr
           Product: gcc
           Version: 5.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dreifachstein at gmail dot com
  Target Milestone: ---

I think g++ incorrectly assumes a constexpr cannot be created from a
non-constexpr function call.
Here is a test case:

struct T {
  static constexpr auto Create() { return 0; }
};

void test()
{
  auto v0 = ([](){ return T(); })(); // not a constexpr
  static_assert(0 == v0.Create(), ""); // pass

  constexpr auto v1 = ([](){ return T(); })().Create(); // error
}

Reply via email to