https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51405
Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org Keywords|rejects-valid | Status|NEW |RESOLVED Summary|[9/10/11/12 Regression] |Passing method result to |Passing method result to |constructor treated as |constructor treated as |function declaration |function declaration | Resolution|--- |FIXED --- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #3) > We started to reject the code in GCC 9 with: > <source>: In function 'int main()': > <source>:43:8: error: trailing return type only available with '-std=c++11' > or '-std=gnu++11' So the bug was fixed in GCC 9. The remaining behavior is just the "most vexing parse": in A a (B::Instance ()->Something ()); We parse a function declaration for a function named a that returns A, with an unnamed parameter which has type function returning B::Instance and a trailing return type of function returning Something, aka int. Now, clearly this is ill-formed, and so we correctly diagnose that the trailing return type requires that the previous declared return type be 'auto'. But this is a semantic rule, not part of the grammar. We could make this work in GCC by catching some of these problems in the parser, but that's not what the standard says. The EDG compiler gives the same error.