From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24814 invoked by alias); 2 Mar 2008 10:57:50 -0000 Received: (qmail 24743 invoked by uid 48); 2 Mar 2008 10:57:06 -0000 Date: Sun, 02 Mar 2008 10:57:00 -0000 Message-ID: <20080302105706.24742.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/28330] finds wrong template overload; peculiar diagnostic In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "truedfx at gentoo dot org" 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: 2008-03/txt/msg00054.txt.bz2 ------- Comment #4 from truedfx at gentoo dot org 2008-03-02 10:57 ------- I only came across this bug looking for something else, but anyway, here's a reduced testcase: template class ring {}; template ring &operator<<(ring&, T *); class base {}; class derived : public base {}; void f() { ring r; derived *d; r << d; } I believe this code is invalid. The template argument can't be deduced, and you'd need something like template class ring {}; template struct non_deducible { typename T type; }; template ring &operator<<(ring&, typename non_deducible::type *); so that only the first argument is considered when choosing which T to use. Or, more simply, make operator<< a member function. -- truedfx at gentoo dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |truedfx at gentoo dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28330