From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21904 invoked by alias); 20 Oct 2012 19:01:09 -0000 Received: (qmail 21867 invoked by uid 48); 20 Oct 2012 19:00:57 -0000 From: "leonid at volnitsky dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55002] New: trailing return type is rejected in function signature Date: Sat, 20 Oct 2012 19:01:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: leonid at volnitsky dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg01839.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55002 Bug #: 55002 Summary: trailing return type is rejected in function signature Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: leonid@volnitsky.com 7.1.6.4 auto specifier [dcl.spec.auto] note 2: The auto type-specifier may appear with a function declarator with a trailing-return-type (8.3.5) in any context where such a declarator is valid=20 Contrived example: ------------------------------------------------------------- typedef unsigned long size_t; // overload c-array template size_t size(T (&)[N]) { return N; } // overload - c-string=20 template size_t size(char (&A)[N]) { size_t i=3D0; while(A[i++]); return i; } // APPLY // this works template size_t apply (const T (&A)[N], size_t (*f)=20= =20=20=20=20=20=20 (const T (&)[N])) // this rejected -- error: parameter declared =E2=80=98auto=E2=80=99 //template size_t apply (const T (&A)[N], auto (*f) -> size_t (const T (&)[N])) { return f(A); }; int main() { int A[2]; return apply(A, size); } ------------------------------------------------------------------ Without trailing return type in signature it is impossible to write apply-l= ike function with can deduce function-type for overloaded functions.