From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19656 invoked by alias); 7 Mar 2012 17:17:50 -0000 Received: (qmail 19641 invoked by uid 22791); 7 Mar 2012 17:17:46 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Mar 2012 17:17:30 +0000 From: "dgsteffen at numerica dot us" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52522] New: Overloaded functions called with initializer lists considered ambiguous Date: Wed, 07 Mar 2012 17:17: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: dgsteffen at numerica dot us 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-03/txt/msg00636.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52522 Bug #: 52522 Summary: Overloaded functions called with initializer lists considered ambiguous Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: dgsteffen@numerica.us Consider: #include using std::vector; class Matrix{}; class Vector{}; Matrix horizontalConcat(const std::vector& vectors); Matrix horizontalConcat(const std::vector& matrices); int main() { Matrix a,b; horizontalConcat({a,b}); } GCC 4.4 and 4.5 in C++0X mode (E.G., g++ testA.cpp -c -ansi -std=3Dc++0x ) = accept this code and do the right thing. However, 4.6.3 produces: /usr/local/compilers/4.6/bin/g++ testA.cpp -c -ansi -std=3Dc++0x=20 estA.cpp: In function =E2=80=98int main()=E2=80=99: testA.cpp:25:24: error: call of overloaded =E2=80=98horizontalConcat()=E2=80=99 is ambiguous testA.cpp:25:24: note: candidates are: testA.cpp:12:8: note: Matrix horizontalConcat(const std::vector&) testA.cpp:13:8: note: Matrix horizontalConcat(const std::vector&) However, sending an initializer list containing 3 or more Matrices works fi= ne.=20 Also, removing the vector overloaded function removes the warning. In principle there could be some ambiguity, when using an initializer list = of two elements, between calling vector's initializer list ctor or calling one= of its other ctors, but here I don't see that either, since vector doe= sn't have a ctor that takes two matrices. At any rate, either GCC 4.6 is incorrectly concluding that the function cal= l is ambiguous, or it's producing a very confusing error message. Thanks very much.