On Sun, Aug 16, 2020 at 7:14 PM Bruno Haible <[email protected]> wrote: > > Hi Florian, > > > > clang (at least in version >= 4), in C++ mode, supports the 'throw > > > ()' declaration on functions, and uses it to optimize try/catch > > > statements at the caller site. > > > > I think throw() has been removed from C++20: > > > > <http://eel.is/c++draft/except.spec> > > <https://en.cppreference.com/w/cpp/language/except_spec> > > > > So it will soon break again. > > Thanks for the heads-up. But g++ 10.2.0 still understands this > "removed" syntax: > > ==================== nothrow.cc ==================== > extern int validate (int x) throw (); > extern void err (int e); > > int foo (int x, int y) > { > try { validate (x); } catch (int e) { err (e); } > try { validate (y); } catch (int e) { err (e); } > return x + y; > } > ==================================================== > $ g++ -O2 -S -std=c++20 -Wall nothrow.cc > <no error, no warning> > > And glibc/misc/sys/cdefs.h has not been updated yet. Is it certain > that GCC and the GCC compatible compilers (clang, icc, etc.) will > continue to support 'throw ()'?
Exception specifications have been deprecated for about a decade. Prior to deprecation they fell out of favor and were not recommended. Also see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3051.html. About the only place I see them in modern software is 'noexcept(false)' when a destructor throws. Jeff
