Consider the following code:
#include <vector>
struct temp {
int& get() { return i; }
int i = 1;
};
int main() {
std::vector<int> v;
v.push_back(temp{}.get());
}
Is the above well-formed code or UB?
My doubts are about the reference returned from get(), which becomes dangling at the last semicolon. But at this point push_back is already evaluated, so it's ok, isn't it?