https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65775
Bug ID: 65775 Summary: Late-specified return type bypasses return type checks (qualified, function, array) Product: gcc Version: 4.9.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ed at catmur dot co.uk If a function declaration has a late-specified return type the usual checks on return types are bypassed: using Qi = int const volatile; Qi q1(); // warning: type qualifiers ignored on function return type auto q2() -> Qi; // no warning using Fi = int(); Fi f1(); // error: 'f1' declared as function returning a function auto f2() -> Fi; // error: function return type cannot be function using Ai = int[5]; Ai a1(); // error: 'a1' declared as function returning an array auto a2() -> Ai; // no error Qualifiers: previously filed as bug 38797 RESOLVED INVALID; I don't entirely agree with the resolution but am willing to let it stand. Function: shows an inconsistent and less informative error, issuing later from gcc/tree.c build_function_type(). Array: the function returning a (prvalue) array is allowed to be declared and can even be defined, called and the result subscripted, though not at -Werror=pedantic: http://stackoverflow.com/q/29628571/567292 I think it should be possible to move at least the function and array return checks to after late-specified return type evaluation.