auto* fun()->int*{}
int main(){
}
This snippet is rejected by both Clang and GCC, and they report an error, which is
'fun' function with trailing return type has 'auto*' as its type rather than plain 'auto'
However, I haven't found any rule that forbids this usage in the standard. The only relevant rule that I feel correspond is the following:
In a declaration T D where D has the form
D1 ( parameter-declaration-clause ) cv-qualifier-seq opt ref-qualifier opt noexcept-specifier opt attribute-specifier-seq opt trailing-return-typeand the type of the contained declarator-id in the declaration T D1 is “derived-declarator-type-list T”, T shall be the single type-specifier auto.
However, according to dcl.meaning#3, which says:
Thus, a declaration of a particular identifier has the form
T D
where T is of the form attribute-specifier-seqopt decl-specifier-seq and D is a declarator.
Hence, back to this example, T is auto and the declarator is *fun()->int*. So, T here is a single type-specifier auto, the declaration does not violate any rule. Why do GCC and Clang both reject the valid code? If I miss the rule that forbids this usage in the standard, what's the rule?