This is the mail archive of the gcc-bugs@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]

[Bug libstdc++/25191] exception_defines.h #defines try/catch



------- Comment #46 from bkoz at gcc dot gnu dot org  2008-06-02 22:27 -------

To clarify, I would like to see this solution come into being:

1) -fno-exceptions
This flag turns off C++ exception handling support, which is indicated at
compile time by __GXX_EXCEPTIONS being undefined. Use of the keywords try,
catch, or throw produces an error. As a result, use of most C++ includes will
fail. 

2) -ftransform-exceptions 
This flag transforms the C++ language such that the keywords try, catch, and
throw change meaning. In particular, try blocks are executed "as if"
transformed into "if (true)", catch blocks are executed "as if" transformed
into "if (false)", and throw expressions are discarded. Although this will
compile C++ code that uses exceptions, please note that the resulting error
handling and code paths are decidedly different and is almost certainly not
what the original authors intended. 

At this point, exception_defines.h can just get junked, __throw_exception_again
mechanically changed into throw, documentation updated that reprobates that had
been happily using -fno-exceptions should just use -ftransform-exceptions, etc.
There will be bitching about this change of course, but separating out these
two things will be a blessing for GNU users.  

I believe this solution would fix the problem for all the various communities:

1) C++ purists who want to be able to use all the C++ keywords without
increasing levels of macro uglification
2) C hackers that want to write pseudo C++, or take existing C++ code and "run
it without exceptions"
3) C++ and ObjC++ people who want accurate diagnostics with and without
-fno-exceptions will get them. 

Perhaps this would solve Howard's issue with -fno-exceptions C++ code and
ObjC++ code that uses exceptions, but I don't really understand that issue. 

-benjamin


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25191


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