[cfe-dev] noexcept and local variables

Sean Hunt scshunt at csclub.uwaterloo.ca
Fri May 27 08:50:12 PDT 2011


On 11-05-27 06:36 AM, Sebastian Redl wrote:
>> test.cpp:6:49: error: member access into incomplete type 'A<int>'
>>       void swap(A&   y) noexcept(noexcept(swap(t_, y.t_)));
>
> Clang bug. This is supposed to work per 9.2p2. I don't know what part of
> the class is visible at that point, though. That is, if t_ was declared
> after swap(), would the code still be valid? I don't think it would be,
> but the standard references for this stuff are all over the place.
> (Also, blargh! This will be horrible to fix.)

The entire class is in scope, meaning we have to delay calculation of 
exception specifications until the end of the class - probably using the 
same technology proposed for in-class member initializers.

There is an obvious issue of recursive or mutually recursive noexcept:

void f() noexcept(noexcept(f()));

struct foo {
   void a() noexcept(noexcept(b()));
   void b() noexcept(noexcept(a()));
};

I've submitted a defect report this about this and other issues 
encountered with noexcept. I believe we can successfully catch issues of 
recursion, and that they should be considered ill-formed (potentially no 
diagnostic required).

Sean



More information about the cfe-dev mailing list