From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22240 invoked by alias); 16 Aug 2014 01:14:14 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 20758 invoked by uid 89); 16 Aug 2014 01:14:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=BAYES_00,MISSING_MID,RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: filter02.roch.ny.frontiernet.net Received: from filter02.roch.ny.frontiernet.net (HELO filter02.roch.ny.frontiernet.net) (66.133.183.227) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 16 Aug 2014 01:14:07 +0000 Received: from localhost (localhost [127.0.0.1]) by filter02.roch.ny.frontiernet.net (Postfix) with ESMTP id 69BD938EA6; Sat, 16 Aug 2014 01:14:05 +0000 (UTC) Received: from relay04.roch.ny.frontiernet.net ([66.133.182.167]) by localhost (filter02.roch.ny.frontiernet.net [66.133.183.227]) (amavisd-new, port 10024) with LMTP id AmfgqC-ekkiq; Sat, 16 Aug 2014 01:13:53 +0000 (UTC) X-Previous-IP: 50.49.151.53 Received: from HOME.frontiernet.net (unknown [50.49.151.53]) by relay04.roch.ny.frontiernet.net (Postfix) with ESMTPA id 8422917CE4; Sat, 16 Aug 2014 01:13:51 +0000 (UTC) Date: Sat, 16 Aug 2014 01:14:00 -0000 To: gcc-help@gcc.gnu.org From: Sidney Marshall Subject: C++11 - Parameter pack question Cc: sidneym@frontiernet.net Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; format=flowed Content-Transfer-Encoding: quoted-printable X-SW-Source: 2014-08/txt/msg00113.txt.bz2 Message-ID: <20140816011400.pXUHX0IFDF_n3xjg0DbvOT-XZz56z_PYJGdr9qAtOTo@z> Hello, The following code compiles and runs correctly but gives a warning: ---------------------------------------- #include using namespace std; template T sum(T value) { return value; } template auto sum(T value, U ... values) { return value + sum(values ...); } int main() { cout << sum(1, 2, 4.6) << endl; cout << sum(1, "abcde", 2) << endl; } -------------------------------------- $ g++ -std=3Dc++11 pack.cpp pack.cpp:11:31: warning: =E2=80=98sum=E2=80=99 function uses=20 =E2=80=98auto=E2=80=99 type specifier without trailing return type [enabled= by default] auto sum(T value, U ... values) { $ ./a.exe 7.6 de ------------------------------------------- All of my attempts to use a trailing return type=20 failed (and I believe should have failed according to the standard). My two questions: 1. What possible user mistake is the warning worried about? 2. How can I write my code with better style so that there is no warning? Thank you. --Sidney Marshall