Bug 64276 - would be better to use __cpp_exceptions rather than __EXCEPTIONS to determine whether exceptions are available
Summary: would be better to use __cpp_exceptions rather than __EXCEPTIONS to determine...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Jonathan Wakely
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-11 19:41 UTC by Richard Smith
Modified: 2014-12-12 16:00 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-12-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Smith 2014-12-11 19:41:02 UTC
libstdc++ uses __EXCEPTIONS to determine wither exceptions are available, and uses __GXX_RTTI to determine if RTTI is available. __EXCEPTIONS is ambiguous; it can mean either "generate cleanups on exception unwind paths" or "allow C++ exception handling syntax", and some compilers allow these flags to be set independently. It would be more portable (and would set a better example) to use __cpp_exceptions and __cpp_rtti rather than these macros, now that GCC supports them.
Comment 1 Andrew Pinski 2014-12-12 03:50:37 UTC
I don't think it matters as libstdc++ is only designed to be compiled with gcc. In fact if used with another compiler, the runtime exception no longer applies.
Comment 2 Jakub Jelinek 2014-12-12 07:52:24 UTC
A Compilation Process is "Eligible" if it is done using GCC, alone or
with other GPL-compatible software, or if it is done without using any
work based on GCC. For example, using non-GPL-compatible Software to
optimize any GCC intermediate representations would not qualify as an
Eligible Compilation Process.

so I think you're wrong on this, the runtime exception can be used even when code is compiled by other compilers, if they aren't based on GCC.
Comment 3 Jonathan Wakely 2014-12-12 11:26:16 UTC
There is no reason not to make this change, __cpp_exceptions is the portable, WG21-recommended way to tell if the compiler supports try/catch.
Comment 4 Jonathan Wakely 2014-12-12 15:59:20 UTC
Author: redi
Date: Fri Dec 12 15:58:49 2014
New Revision: 218679

URL: https://gcc.gnu.org/viewcvs?rev=218679&root=gcc&view=rev
Log:
	PR libstdc++/64276
	* doc/doxygen/user.cfg.in: Define __cpp_exceptions and __cpp_rtti.
	* doc/html/manual/using_exceptions.html: Regenerate.
	* doc/xml/manual/using_exceptions.xml: Use SD-6 feature-testing
	macros, __cpp_exceptions and __cpp_rtti, instead of __EXCEPTIONS and
	__GXX_RTTI.
	* include/bits/c++config: Likewise.
	* include/bits/locale_classes.tcc: Likewise.
	* include/bits/shared_ptr.h: Likewise.
	* include/bits/shared_ptr_base.h: Likewise.
	* include/debug/formatter.h: Likewise.
	* include/experimental/any: Likewise.
	* include/ext/rope: Likewise.
	* include/ext/ropeimpl.h: Likewise.
	* include/std/functional: Likewise.
	* include/tr1/functional: Likewise.
	* include/tr1/shared_ptr.h: Likewise.
	* libsupc++/eh_call.cc: Likewise.
	* libsupc++/eh_personality.cc: Likewise.
	* libsupc++/exception_defines.h: Likewise.
	* libsupc++/exception_ptr.h: Likewise.
	* libsupc++/guard.cc: Likewise.
	* libsupc++/pbase_type_info.cc: Likewise.
	* libsupc++/pointer_type_info.cc: Likewise.
	* libsupc++/vterminate.cc: Likewise.
	* src/c++11/thread.cc: Likewise.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/doc/doxygen/user.cfg.in
    trunk/libstdc++-v3/doc/html/manual/using_exceptions.html
    trunk/libstdc++-v3/doc/xml/manual/using_exceptions.xml
    trunk/libstdc++-v3/include/bits/c++config
    trunk/libstdc++-v3/include/bits/locale_classes.tcc
    trunk/libstdc++-v3/include/bits/shared_ptr.h
    trunk/libstdc++-v3/include/bits/shared_ptr_base.h
    trunk/libstdc++-v3/include/debug/formatter.h
    trunk/libstdc++-v3/include/experimental/any
    trunk/libstdc++-v3/include/ext/rope
    trunk/libstdc++-v3/include/ext/ropeimpl.h
    trunk/libstdc++-v3/include/std/functional
    trunk/libstdc++-v3/include/tr1/functional
    trunk/libstdc++-v3/include/tr1/shared_ptr.h
    trunk/libstdc++-v3/libsupc++/eh_call.cc
    trunk/libstdc++-v3/libsupc++/eh_personality.cc
    trunk/libstdc++-v3/libsupc++/exception_defines.h
    trunk/libstdc++-v3/libsupc++/exception_ptr.h
    trunk/libstdc++-v3/libsupc++/guard.cc
    trunk/libstdc++-v3/libsupc++/pbase_type_info.cc
    trunk/libstdc++-v3/libsupc++/pointer_type_info.cc
    trunk/libstdc++-v3/libsupc++/vterminate.cc
    trunk/libstdc++-v3/src/c++11/thread.cc
Comment 5 Jonathan Wakely 2014-12-12 16:00:22 UTC
Done.