From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1156 invoked by alias); 15 Jan 2002 14:16:05 -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 1114 invoked by uid 71); 15 Jan 2002 14:16:03 -0000 Resent-Date: 15 Jan 2002 14:16:03 -0000 Resent-Message-ID: <20020115141603.1113.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, Martin von Loewis Received:(qmail 28512 invoked from network); 15 Jan 2002 14:08:33 -0000 Received: from unknown (HELO mail.informatik.hu-berlin.de) (141.20.20.50) by sources.redhat.com with SMTP; 15 Jan 2002 14:08:33 -0000 Received: from kosh.informatik.hu-berlin.de (mail@kosh [141.20.23.210]) by mail.informatik.hu-berlin.de (8.11.3/8.11.3/INF-2.0-MA-SOLARIS-2.8) with ESMTP id g0FE8VB16408; Tue, 15 Jan 2002 15:08:31 +0100 (MET) Received: from loewis by kosh.informatik.hu-berlin.de with local (Exim 3.33 #1 (Debian)) id 16QUGN-0003QK-00; Tue, 15 Jan 2002 15:08:31 +0100 Message-Id: Date: Tue, 15 Jan 2002 06:16:00 -0000 From: Martin von Loewis To: gcc-gnats@gcc.gnu.org, debian-gcc@lists.debian.org X-Send-Pr-Version:3.113 Subject: c++/5388: X-SW-Source: 2002-01/txt/msg00561.txt.bz2 List-Id: >Number: 5388 >Category: c++ >Synopsis: >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: rejects-legal >Submitter-Id: net >Arrival-Date: Tue Jan 15 06:16:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Martin v. Loewis Release: 3.0.3 (Debian testing/unstable) >Organization: >Environment: System: Linux kosh 2.4.13-586-ext3 #1 Die Nov 6 00:09:32 CET 2001 i686 unknown Architecture: i686 host: i386-pc-linux-gnu build: i386-pc-linux-gnu target: i386-pc-linux-gnu configured with: ../src/configure -v --enable-languages=c,c++,java,f77,proto,objc --prefix=/usr --infodir=/share/info --mandir=/share/man --enable-shared --with-gnu-as --with-gnu-ld --with-system-zlib --enable-long-long --enable-nls --without-included-gettext --disable-checking --enable-threads=posix --enable-java-gc=boehm --with-cpp-install-dir=bin --enable-objc-gc i386-linux >Description: Compiling the program below gives the message operands to ?: have different types I believe that this message is incorrect, according to 5.16/3: One is a base class of the other, so the resulting type of the expression is A. #include class A { public: A() {} virtual void print() const { printf("I'm A\n"); } A& operator=(const A&) { printf("A asignment\n"); return *this; } static const A& Convert(const A&x){ return x; } }; class B : public A { public: B() {} B(const A&) { printf("A to B conversion\n"); } B& operator=(const B&) { printf("B asignment\n"); return *this; } virtual void print() const { printf("I'm B\n"); } static const B& Convert(const B&x){ return x; } }; A& getA() { static A *a = new A; return *a; } B& getB() { static B *b = new B; return *b; } main() { bool b = true; getA() = b ? A() : B(); // correct } >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: