From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5103 invoked by alias); 5 Dec 2002 13:06:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 5082 invoked by uid 71); 5 Dec 2002 13:06:01 -0000 Resent-Date: 5 Dec 2002 13:06:01 -0000 Resent-Message-ID: <20021205130601.5081.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, andre@kiwisound.de Received: (qmail 2220 invoked by uid 61); 5 Dec 2002 12:56:08 -0000 Message-Id: <20021205125608.2219.qmail@sources.redhat.com> Date: Thu, 05 Dec 2002 05:06:00 -0000 From: andre@kiwisound.de Reply-To: andre@kiwisound.de To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/8821: gcc 3.2 problem with overloaded inherited operator X-SW-Source: 2002-12/txt/msg00271.txt.bz2 List-Id: >Number: 8821 >Category: c++ >Synopsis: gcc 3.2 problem with overloaded inherited operator >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Thu Dec 05 05:06:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Andre Mueller >Release: gcc version 3.2 >Organization: >Environment: Linux version 2.4.19-4GB >Description: A operator with a user class from a base class A will not be found if a derived class B overloads this operator. > g++ tst.cpp tst.cpp: In function `int main(int, char**)': tst.cpp:16: no match for `B& << Z&' operator tst.cpp:10: candidates are: void B::operator<<(int) >How-To-Repeat: class Z { }; class A { public: void operator << ( const Z & ) { } }; class B : public A { public: void operator << ( int ) { } }; int main( int , char ** ) { B b; Z z; b << z; // Oops!? Why is it not possible to compile this? return 0; } >Fix: An explicit downcast is necessary: Replace the line b << z with static_cast(b) << z; >Release-Note: >Audit-Trail: >Unformatted: