Compiling with gcc-4.0.0 and -fno-exceptions

Daniel Kegel dank@kegel.com
Tue Jun 7 18:16:00 GMT 2005


Paolo Carlini wrote:
> When -fno-exceptions, 'try' becomes 'if (true)' and 'catch(X)' becomes
> 'if (false)': my guess would be that a sufficiently smart compiler
> should be able to figure out statically that the no-return branch is
> never taken. Can you possibly check whether mainline and 4.0.1 pre are
> also affected?

recent 4.1 is not affected.  4.0-20050602 is, sadly, affected.

> For sure we had quite a few of those spurious warnings in
> Bugzilla and most have been fixed. I would suggest trying to figure
> which is the current situation in Bugzilla, 4.0.1 pre, and mainline (I
> can also do that, of course, but would appreciate a stand-alone snippet
> from your work) and then take the appropriate action. Changing the
> library seems not an option.

Filed as http://gcc.gnu.org/PR21951
which was immediately marked as a duplicate of
http://gcc.gnu.org/PR19699, since my bugzilla searching skills
are obviously not up to par!

I will work around this in my local copy of libstdc++ by adding

+#ifdef __EXCEPTIONS
        catch(...)
         {
           std::_Destroy(__result, __cur);
           __throw_exception_again;
         }
+#endif

to fix the "silliness" in libstdc++, as suggested by Andrew Pinski.

Thanks,
Dan



More information about the Libstdc++ mailing list