On Sunday, 15 August 2021 at 20:23:03 UTC, Paul Backus wrote:
On Sunday, 15 August 2021 at 18:47:27 UTC, Tejas wrote:
Do you see anything wrong with the following `emplace`-allocated, RAII following exceptions:

[...]

Is this good enough for general use now? Any other drawbacks?

It only works if you're throwing and catching in the same function. Otherwise you are essentially returning a pointer to an expired stack frame, which is UB.

 Agh >_<

if I remove the `scope`and replace it with `auto`?
No longer having anything to do with the stack or RAII, just using malloc + emplace instead of GC?

Yeah it might leak memory unless the catch block explicitly frees the exception object, but other than that?

Reply via email to