[cfe-dev] Fwd: is it correct in C++: exception in typedef

Liu Xin via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 6 01:51:09 PDT 2016


hi, CFE list,

I wonder if C++ allows to declare exception spec in typdef.

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


thanks,
--lx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160406/86788598/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.cpp
Type: text/x-c++src
Size: 200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160406/86788598/attachment.cpp>


More information about the cfe-dev mailing list