[cfe-dev] noexcept and local variables

Douglas Gregor dgregor at apple.com
Fri May 27 11:44:02 PDT 2011


On May 27, 2011, at 8:50 AM, Sean Hunt wrote:

> 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.

Right. Default function arguments are another, more closely related, case where we need to delay parsing until the class is fully defined.

> 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).


With default function arguments, the committee decided to consider the program ill-formed if a default argument for a member function declared earlier in the class relies on a default argument declared later in the class. I expect that the committee would do the same here.

	- Doug



More information about the cfe-dev mailing list