bug-gnulib
[Top][All Lists]
Advanced

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

Re: C++ throw() clause


From: Bruno Haible
Subject: Re: C++ throw() clause
Date: Mon, 17 Aug 2020 01:13:57 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

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 ()'?

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]