[LLVMdev] RFC: Exception Handling Proposal Revised

Duncan Sands baldrick at free.fr
Wed Dec 1 11:42:30 PST 2010


Hi Bill,

...
> I don't understand what you're trying to say here. I looked at the assembly for
> your first bar() function and it's exactly the same as would be emitted for one
> without the new scopes. Indeed, it's semantically identical. What do you mean by
> "before the try scope is reached"? If an exception is thrown by something in a
> nested scope, any variables live at that point must have their cleanups called
> before exiting the try block. And that occurs before the catch handlers are called.
>
>> Consider the following example instead:
>>
>> void bar() {
>> try {
>> A a;
>> foo();
>> } catch (int i) {
>> ... etc ...
>> }
>>
>> If you check the assembler you will see that the destructor for "a" is run
>> before branching to the handler.
>>
> Correct. How is this a contradiction of what I wrote? I'm confused.

I got myself confused.  Indeed it seems that C++ behaves the way you describe.
However in Ada it is the other way round: cleanups are run after handlers.  For
example in Ada it would be possible to use the variable "a" inside one of the
handlers, so it had better not be destructed before the handler runs.  Thus it
is important not to bake "cleanups run before handlers" into your proposal,
since it is C++ specific.  That said, as far as I can tell you didn't bake it
in.

Ciao,

Duncan.



More information about the llvm-dev mailing list