[cfe-dev] Exception Specs & Redeclarations

Douglas Gregor dgregor at apple.com
Sun Mar 6 10:27:56 PST 2011


On Mar 6, 2011, at 4:35 AM, Sebastian Redl wrote:

> 
> On 06.03.2011, at 12:54, Sebastian Redl wrote:
> 
>> Hi,
>> 
>> My opinion is that the standard is broken here. noexcept(false) shouldn't be compatible with throw(X) specifiers. That can only lead to chaos.
>> 
>> But if there are important reasons to keep the standard as it is, what would be the best way to implement this?
> 
> After looking through the standard history, I now know the rationale behind this compatibility feature. However, the problem I pointed out remains. I am not sure that the benefit (can update header files to avoid deprecation warnings in client code, without having to update source files) outweighs the cost (really messy redecl merging - and I can't believe Clang is the only compiler to suffer from this).
> 
> However, assuming that others do not share my opinion here, I think a narrower wording would be beneficial. In particular:
> 1) A throw(X) specifier *on a definition only* should be compatible with noexcept(false) on declarations. (I realise that would be tricky to get right in Clang.)
> and/or 2) The compatibility rule does not apply to function templates. (Or at least, and that's what I'm actually going to implement for now, dependent noexcept specifiers are incompatible with dynamic specifiers.)

Check out 

	http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1073

which strikes the problematic compatibility rule. Let's assume the proposed resolution; IIRC, it's what GCC does.

	- Doug



More information about the cfe-dev mailing list