I
Ian Collins
That's the first time I've heard the expression "SEME safe
code". We speak of exception safety because exceptions
introduce invisible edges in the flow graph; we also only use
exceptions in cases where we've abandonned trying to achieve
a significant part of the normal post-conditions. Neither is
necessarily true with SEME.
I think I understand what you're trying to say, but I think your
confounding two separate issues.
Or maybe I'm not expressing my self clearly.
I have been working with a lot of filesystem C code with functions that
allocate stuff as they go and when they hit an error and can't progress
"goto cleanup".
Obviously being C the code isn't exception safe and would certainly leak
like a sieve if anyone were to add an early return. If I had to convert
the code to exception safe C++, the first thing I would do is wrap the
allocated resources in an auto_ptr like object to ensure no mess was
left behind if an exception was thrown.
Having done that, I could probably also replace most of the "goto
cleanup" lines with a return of the appropriate error code.
So what I'm saying is code written to be exception safe is generally
early return safe. Yes there are cases where certain post conditions
require SESE, but they are probably uncommon.
I also accept your point regarding machine reasoning of program
correctness, but I don't think many projects have access to requirements
to use such tools. If they did, we wouldn't have software bugs, would we