[cfe-dev] Fwd: is it correct in C++: exception in typedef
Richard Smith via cfe-dev
cfe-dev at lists.llvm.org
Wed Apr 6 14:53:41 PDT 2016
On Wed, Apr 6, 2016 at 1:51 AM, Liu Xin via cfe-dev <cfe-dev at lists.llvm.org>
wrote:
> hi, CFE list,
>
> I wonder if C++ allows to declare exception spec in typdef.
>
No current C++ standard allows this. C++17 will (and more generally,
exception specifications become a first-class part of the type system in
C++17), but this feature is not yet implemented (see
http://clang.llvm.org/cxx_status.html#cxx17).
> eg.
> typedef int name() throw(int) ;
>
> I tested t.cpp using g++/clang, they all forbid this behavior.
>
> clang gives me quite clear answer.
> t.cpp:4:20: error: exception specifications are not allowed in typedefs
> typedef int name() throw(int) ;
> ^
> t.cpp:5:24: error: exception specifications are not allowed in typedefs
> typedef int (*pname)() throw(int) ;
> ^
> t.cpp:6:24: error: exception specifications are not allowed in typedefs
> typedef int (&rname)() throw(int) ;
> ^
> 3 errors generated.
>
> t.cpp is actually from microsoft's AMP testsuite. I believe VC++ accepts
> it (sorry, I didn't verify using vc++, because I can't access windows by
> now).
>
> According to my google result, N4533 and P0012R1 try to remove this
> restriction, am I right?
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html
>
Correct. They also make 'throw(int)' a deprecated synonym of
'noexcept(false)'. I suspect MSVC just doesn't implement the C++98 rule,
rather than already implementing the P0012 rule...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160406/3fedb0bb/attachment.html>
More information about the cfe-dev
mailing list