Re: C++11: Using noexcept



On Sun, 2015-08-16 at 13:12 +0200, Murray Cumming wrote:
I guess we could use noexcept on lots of our class methods -
particularly simple boxed types such as Gdk::Rectangle, but maybe even
anything that doesn't wrap a GError in an exception.

Using noexcept seems to be more worthwhile than using throw() was,
letting the compiler optimize more.

It looks like adding noexcept doesn't break ABI. Does anyone know
otherwise?

Doing some very simple tests and reading the documentation the noexcept
specifier does not form part of the mangled name very much like throw().
So I expect that this would break any ABI

int f(int a) noexcept
{
  return a;
}

and

int f(int a)
{
  return a;
}

Both produce exactly the same code using GCC and Clang. If they were
compiled together there will a compilation error with both being treated
as -

int f(int);

One thing to watch out for is that C code can throw an exception. One
way that this can be done is by declaring a function extern "C" during
"C++" compilation and throwing and exception there. There is probably
more ways to do this.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]