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]
Other format: [Raw text]

Re: __attribute__((cleanup(function)) versus try/finally


> Err...  You're not using try/finally above,

That was my point: try/finally isn't really the ideal construct.

Your version does work, of course -- as does my try/catch expression of
the idea, modulo your comments below.

> and you're not necessarily
> using the values of f and a that were passed to pthread_cleanup_push.

This was a mistake, thanks.  You're right that the values need to be
saved, of course.

I agree that all of this is parenthetical; the key question is whether C
needs to have EH constructs or not, not which particular constructs they
are.

Let's just drop that train of thought; it's not going to be productive. 
I was just musing.

It would be nice, though, if the "goto" issue got back to the right
people; that should definitely be specified.  In the same light, the
behavior of "break" and "continue" should be specified; those are also
ways of exiting the scope.  

Undefined behavior might be the right answer.  Running the cleanup might
not be a good idea; the argument to pthread_cleanup_pop means that the
designers thought that sometimes you don't want to run the cleanup. 
(It's not really like a C++ destructor.)  

Maybe jumping out of the scope should just be ill-formed, no diagnostic
required.

I'm not sure, but this isn't the right forum to decide anyhow; I'd just
like for the POSIX people to know about the issue.

-- 
Mark Mitchell <mark@codesourcery.com>
CodeSourcery, LLC


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