C++ – using const reference to prolong a member of a temporary, ok or UB?

Your code should be well-formed, because for temporaries (emphasis mine) Whenever a reference is bound to a temporary or to a subobject thereof, the lifetime of the temporary is extended to match the lifetime of the reference Given A().b[4], b[4] is the subobject of b and the data member b is the subobject of the … Read more