Re: [eigen] exception specifications...

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 3/14/10, Hauke Heibel <hauke.heibel@xxxxxxxxxxxxxx> wrote:

> I thought it might be a good idea to remove the throw() declarations

For as long as you retain your lib as 'header-only' one (i.e. no
shared lib files) -- with using extern/global functions et al, the
explicit "throw()" qualifier allows some compilers to optimize things
that they otherwise would/could not...

For instance, from:
http://gcc.gnu.org/gcc-4.1/changes.html
we have:
"
When generating code for a shared library, GCC now recognizes that
global functions may be replaced when the program runs. Therefore, it
is now more conservative in deducing information from the bodies of
functions. For example, in this example:

    void f() {}
    void g() {
     try { f(); }
     catch (...) {
       cout << "Exception";
     }
    }

G++ would previously have optimized away the catch clause, since it
would have concluded that f cannot throw exceptions. Because users may
replace f with another function in the main body of the program, this
optimization is unsafe, and is no longer performed. If you wish G++ to
continue to optimize as before, you must add a throw() clause to the
declaration of f to make clear that it does not throw exceptions.
"

Kind regards
Leon.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/