Page MenuHomePhabricator

[ExprConstant] Fix assert when initializing constexpr array
Needs ReviewPublic

Authored by erik.pilkington on Nov 22 2017, 11:22 AM.

Details

Reviewers
rsmith
Summary

Previously, clang would assert on the following:

struct S {
  constexpr S (const int& ir = 0) {}
};
constexpr S foo[2];

The problem was that while initializing foo, CallStackFrame::createTemporary() was called twice for the MaterializeTemporaryExpr for 0 in the default constructor (once for each array element) without ending the lifetime of the first. This caused createTemporary() to assert. This patch fixes this problem by separating the lifetime of temporaries created for successive calls to the ctor when initializing arrays.

https://bugs.llvm.org/show_bug.cgi?id=34858

Thanks for taking a look!
Erik

Diff Detail

Event Timeline