What is throw?

ballsystemlord doark@mail.com
Fri Nov 22 14:36:00 GMT 2013

My appologies I got gcc and Gnu-libc mixed up a little.
It's not '__throw' it's 'throw'.

     Check that the pointer returned by `operator new' is non-null
     before attempting to modify the storage allocated.  This check is
     normally unnecessary because the C++ standard specifies that
     `operator new' will only return `0' if it is declared `throw()',
     in which case the compiler will always check the return value even
     without this option.  In all other cases, when `operator new' has
     a non-empty exception specification, memory exhaustion is
     signalled by throwing `std::bad_alloc'.  See also `new (nothrow)'.

     Don't generate code to check for violation of exception
     specifications at run time.  This option violates the C++
     standard, but may be useful for reducing code size in production
     builds, much like defining `NDEBUG'.  This does not give user code
     permission to throw exceptions in violation of the exception
     specifications; the compiler will still optimize based on the
     specifications, so throwing an unexpected exception will result in
     undefined behavior.

     Treat a `throw()' exception specification as though it were a
     `noexcept' specification to reduce or eliminate the text size
     overhead relative to a function with no exception specification.
     If the function has local variables of types with non-trivial
     destructors, the exception specification will actually make the
     function smaller because the EH cleanups for those variables can be
     optimized away.  The semantic effect is that an exception thrown
     out of a function with such an exception specification will result
     in a call to `terminate' rather than `unexpected'.

     Warn for cases where adding an attribute may be beneficial. The
     attributes currently supported are listed below.

          Warn about functions that might be candidates for attributes
          `pure', `const' or `noreturn'.  The compiler only warns for
          functions visible in other compilation units or (in the case
          of `pure' and `const') if it cannot prove that the function
          returns normally. A function returns normally if it doesn't
          contain an infinite loop nor returns abnormally by throwing,
          calling `abort()' or trapping.  This analysis requires option
          `-fipa-pure-const', which is enabled by default at `-O' and
          higher.  Higher optimization levels improve the accuracy of
          the analysis.

     On systems that provide `libgcc' as a shared library, these options
     force the use of either the shared or static version respectively.
     If no shared version of `libgcc' was built when the compiler was
     configured, these options have no effect.

     There are several situations in which an application should use the
     shared `libgcc' instead of the static version.  The most common of
     these is when the application wishes to throw and catch exceptions
     across different shared libraries.  In that case, each of the
     libraries as well as the application itself should use the shared

     Generate code that allows trapping instructions to throw
     exceptions.  Note that this requires platform-specific runtime
     support that does not exist everywhere.  Moreover, it only allows
     _trapping_ instructions to throw exceptions, i.e. memory
     references or floating-point instructions.  It does not allow
     exceptions to be thrown from arbitrary signal handlers such as

     The `nothrow' attribute is used to inform the compiler that a
     function cannot throw an exception.  For example, most functions in
     the standard C library can be guaranteed not to throw an exception
     with the notable exceptions of `qsort' and `bsearch' that take
     function pointer arguments.  The `nothrow' attribute is not
     implemented in GCC versions earlier than 3.3."

So, what is throw?

View this message in context: http://gcc.1065356.n5.nabble.com/What-is-throw-tp985729p988442.html
Sent from the gcc - Help mailing list archive at Nabble.com.

More information about the Gcc-help mailing list