This is the mail archive of the gcc-patches@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: [basic-improvements] try/finally support for c/c++ - more tests


See elsewhere about resistance compiling libc with a c++ compiler.
I know there's resistance, but frankly I think that's just predjudice.

Compile the bits you need C++ features for in C++.  Avoid stuff that
seems fragile, like virtual bases/virtual functions etc; just use
try/catch and/or destructors if that's all you want.  The functionality
you need has been stable for ages and ages.

I feel strongly that we should not try to bring C++ features into C,
just to avoid having to compile some stuff in libc with G++.  Especially
as similar features may eventually go into ISO C with subtly different
semantics.

The main problem is that you simply cannot implement cleanups with
a few calls to a runtime library.  There are data structures that
the compiler must set up related to how it generated code.

If we do want to check these patches in, the semantics should be given
in terms of translation to (1) above.
I should have said (1) or (2).  I'm comfortable with either formulation,
and you're right that they are subtly different.  If we do (2), we have
to word it cleverly; a literal substitution wouldn't work because local
variables wouldn't be available in S::~S.

Further, try/catch/rethrow does not express what happens when
you use goto/break/continue/return to leave the try block.
True.

I don't want to distract us by getting into that; I'm happy to go with
the translation (2) which seems to be what you prefer, if we decide
we absolutely must introduce this feature.

I, however, am far from convinced.

--
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


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