[petsc-dev] CHKERRXX() to propagate errors from C

Jed Brown jedbrown at mcs.anl.gov
Wed Oct 19 15:02:32 CDT 2011


On Wed, Oct 19, 2011 at 14:57, Matthew Knepley <knepley at gmail.com> wrote:

>    The properly manage the clean up of partially created objects etc don't
>> they, which our C approach cannot handle. Not that I'm advocating for using
>> them or not.
>
>
> Hmm, I do not see how. As far as I know, you need logic to do that once you
> catch them, which we could also put in.
>

Destructors for any live automatic (stack) allocated are called when an
exception is raised. Of course it causes all manner of havoc if any of these
destructors fail, but having them called means that you can use RAII and
"simply" have code that can unwind cleanly. That control flow is much harder
with return codes because you end up with either lots of gotos to unwind
from each place that can fail or deeply nested control structures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20111019/4bbbf484/attachment.html>


More information about the petsc-dev mailing list