[cfe-dev] Exception Specs & Redeclarations

Sebastian Redl sebastian.redl at getdesigned.at
Sun Mar 6 04:35:07 PST 2011


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

Sebastian



More information about the cfe-dev mailing list