This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: CLEANUP_POINT_EXPR/WITH_CLEANUP_EXPR vs TRY_CATCH_EXPR


    Yes, but why should they?  Imagine n new languages and 2 old
    languages.  If n is > 2, it is more work.  

That's an odd way of counting work.  I count adding one line to new code as a
negligable amount of work.  But handling the confusion resulting from not
being able to have a single front end work with both the old and new version
of the compiler an extraordinary cost, distributed to many of the potential
users of the compiler.

    I think there is a miscommunication.  In expand_decl_cleanup type of
    things, which seem to be used by the Ada front end, else there
    wouldn't be a need for this flag, those actions are what I refer to
    when I say cleanup.  Upon an exception I think the Ada spec says these
    actions are performed in a certain order and so on when an exception
    happens.  In order for them to happen, you walk a list at run time and
    perform actions off the list.  This is the code I refer to. 

Those are used both for EH and non-EH purposes!  Cleanups are also run when a
block is exited via a jump out of the block.  There's nothing in the
documentation that says that you have to use EH if you want to force an
action to be done when a block is exited either by a jump or by falling
through.  More to the point, that use of cleanups *predated* the EH code, as
I said before, so the EH code had the effect of breaking it for compilers
that just wanted that use as a cleanup.  My change fixed that and you are
proposing to break it again.

    This is as I recall handled by the Ada front end.  Maybe they only
    express themselves in the language under the guise of exception
    handling (try finally)?

No, that's quite wrong. The cleanup actions are added by the Ada front end as
part of the "expander" process, which works on tree nodes and transforms them
into constructs of a lower semantic level (such as inserting calls to library
function).  The part of the front end that deals with cleanup actions is one
of the most complex parts of it and one I don't understand very well, but I
do know that they have nothing to do with exceptions at the source level:
they are generated from constructs that use tasking, dynamic allocation, and
controlled types, among other things.

    After the Ada front end is converted, you will understand what I meant
    by replicated code.

The only "replicated code" is that the front end calls the builtin setjmp and
longjmp directly.  This has nothing to do with cleanup actions.  The actual
list of things that need to be done when an exception occurs is handled
outside this entire mechanism and done via library functions since the Ada
language requires a very precise set of semantics for such actions, so they
can't be dealt with using a static nesting of cleanups that the core compiler
provides.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]