>>107880627
>By that definition you'd need a hardware failure, or a catastrophic bug in how your underlying operating system handles your memory, to encounter a "memory error".
No.
For example, if you use a pointer after free that would be considered memory error. This is not just a logic error, this is undefined behavior and that's why it is worse than just breaking some invariants about your statically allocated structure.
>>107880586
Unfortunatelly that doesn't work either
#include <memory>
#include <cstdio>
template<typename T, typename... Args>
T* make_danging(Args&&... args) {
auto smart_ptr = std::make_shared<T>(args...);
return &*smart_ptr;
}
Comment too long. Click here to view the full text.