From mboxrd@z Thu Jan 1 00:00:00 1970 From: philipp.bachmann@obtree.com To: gcc-gnats@gcc.gnu.org Subject: c++/3136: Misleading error message / Bug? Date: Tue, 12 Jun 2001 06:16:00 -0000 Message-id: <20010612130926.18398.qmail@sourceware.cygnus.com> X-SW-Source: 2001-06/msg00478.html List-Id: >Number: 3136 >Category: c++ >Synopsis: Misleading error message / Bug? >Confidential: no >Severity: non-critical >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue Jun 12 06:16:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Philipp Bachmann >Release: g++ 2.95.3 >Organization: >Environment: Sun Solaris 7 SPARC >Description: When "CONST" in the sample code provided is defined to be empty, then the following error message is printed by g++: copyConstr.c++: In function 'class derived_t whatHappensHere(base_t)': copyConstr.c++:74: conversion from 'base_t' to non-scalar type 'derived_t' requested. If either (1) "CONST" is defined as "const" or (2) line 74 is commented out and line 73 is commented in, then the error message completely vanishes. I can understand the necessity for "const" (i.e. Fix (1)) - but that Fix (2) solves the problem I'm surprised about. So my interpretation is twofold: The error message is misleading and g++ has a small bug. >How-To-Repeat: via Email >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="copyConstr.c++.txt" Content-Disposition: inline; filename="copyConstr.c++.txt" /* Very simple program to demonstrate misleading error message of GNU g++ 2.95.3. */ /* $Log: copyconstr.c++,v $ * Revision 1.2 2001/06/12 13:58:07 bachlipp * Introduced "base_t::getMe() const". * * Revision 1.1 2001/06/12 13:32:39 bachlipp * Initial revision * */ static const char rcsid[]="@@(#)$Id: copyconstr.c++,v 1.2 2001/06/12 13:58:07 bachlipp Exp $"; #include #define CONST // #define CONST const class base_t { public : base_t(void); base_t(const base_t &); virtual ~base_t(void); virtual base_t getMe(void) const; }; class derived_t : public base_t { public: derived_t(void); derived_t(const derived_t &); derived_t(CONST base_t &); ~derived_t(void); }; derived_t whatHappensHere(base_t); base_t::base_t(void) { std::cerr<<"\"base_t::Constructor\" called."<