From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20942 invoked by alias); 7 Dec 2010 04:09:39 -0000 Received: (qmail 20931 invoked by uid 22791); 7 Dec 2010 04:09:36 -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; Tue, 07 Dec 2010 04:09:31 +0000 From: "schaub.johannes at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/46831] [C++0x] Crash when it tries to do an invalid ICS with a conversion function template X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: schaub.johannes at googlemail 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: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 07 Dec 2010 04:09:00 -0000 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: 2010-12/txt/msg00654.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46831 --- Comment #1 from Johannes Schaub 2010-12-07 04:09:25 UTC --- ------------------------------------------------- GCC also rejects this valid code: ---------- struct A { template operator short(); template operator long(); }; void f(long); void f(int); // this call is not ambiguous, but GCC claims it is int main() { f(A()); } Also, if we make the second conversion functon a non-template, GCC suddenly accepts the code (right at it, the code is still valid). But that indicates that GCC has internally the handling of 13.3.3[over.match.best]p1 bullet 4 and bullet 5 reversed: It first checks whether one is a template and the other is a non-template, and only then checks whether the return type of F1 converts better than the return type of F2. -------------------------------------------------- We can make this to crash on valid code, too: -------- struct B { }; struct D : B { }; struct A { template operator D&(); operator long(); }; void f(long); void f(B&); int main() { f(A()); }