Raymond Chen's take on so-called zero cost exceptions

Walter Bright newshound2 at digitalmars.com
Mon Feb 28 20:33:17 UTC 2022


"The presence of exceptions means that the code generation is subject to 
constraints that don’t show up explicitly in the code generation: Before 
performing any operation that could potentially throw an exception, the compiler 
must spill any object state back into memory if the object is observable from an 
exception handler. (Any object with a destructor is observable, since the 
exception handler may have to run the destructor.)
Similarly, potentially-throwing operations limit the compiler’s ability to 
reorder or eliminate loads from or stores to observable objects because the 
exception removes the guarantee of mainline execution."

https://devblogs.microsoft.com/oldnewthing/20220228-00/?p=106296

This is what I've been saying.


More information about the Digitalmars-d mailing list