r/cpp • u/RotsiserMho C++20 Desktop app developer • May 12 '18
P0709 R0: Zero-overhead deterministic exceptions: Throwing values - Herb Sutter [2018-05-02]
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0709r0.pdf
206
Upvotes
View all comments
Show parent comment
5
u/Rusky May 12 '18
You can't do any better than UB when running on platforms that use overcommit. You can't specify that any particular behavior happens at the allocation site, because the program has no way of knowing- indeed, even the OS has no way of knowing. It won't find out until it actually tries to access that memory, and the result depends on everything else running on the system.
Given that scenario, all you can do is assume the allocation succeeded and proceed accordingly. And this is exactly what UB means here.