[PATCH] D136013: [clang][Interp] Fix ignoring expression return values
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 18 06:16:56 PDT 2022
aaron.ballman added inline comments.
================
Comment at: clang/test/AST/Interp/records.cpp:208
+
+struct S {
+ int a = 0;
----------------
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.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136013/new/
https://reviews.llvm.org/D136013
More information about the cfe-commits
mailing list