Randomly noticed this. We need to honor DiscardResult here.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| clang/test/AST/Interp/records.cpp | ||
|---|---|---|
| 208 | Hmmm, this feels related to the discarded value results changes, but it might be a test case for a different scenario as well, so take this or leave it: struct S {
int &Ref;
constexpr S(int &R) : Ref(R) { Ref = 0; }
constexpr ~S() { Ref = 12; }
};
constexpr S get_s(int &i) { return S{i}; }
constexpr int func() {
int i = 1;
{
get_s(i);
}
return i;
}
static_assert(func() == 12);The idea behind the test is -- we construct the S object but discard its results in the compound block, but the dtor still runs as expected. | |
| clang/test/AST/Interp/records.cpp | ||
|---|---|---|
| 208 | I think this would trigger the TODO I added, since this is a RVO function but we have nowhere to write the return value. | |
Hmmm, this feels related to the discarded value results changes, but it might be a test case for a different scenario as well, so take this or leave it:
struct S { int &Ref; constexpr S(int &R) : Ref(R) { Ref = 0; } constexpr ~S() { Ref = 12; } }; constexpr S get_s(int &i) { return S{i}; } constexpr int func() { int i = 1; { get_s(i); } return i; } static_assert(func() == 12);The idea behind the test is -- we construct the S object but discard its results in the compound block, but the dtor still runs as expected.