From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 752 invoked by alias); 23 Apr 2002 15:56:03 -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 685 invoked by uid 71); 23 Apr 2002 15:56:01 -0000 Resent-Date: 23 Apr 2002 15:56:01 -0000 Resent-Message-ID: <20020423155601.684.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, Ben Dorman Received:(qmail 27993 invoked from network); 23 Apr 2002 15:49:39 -0000 Received: from unknown (HELO pcp259033pcs.howard01.md.comcast.net) (68.54.86.98) by sources.redhat.com with SMTP; 23 Apr 2002 15:49:39 -0000 Received: (from dorman@localhost) by pcp259033pcs.howard01.md.comcast.net (8.11.2/8.11.2) id g3NFnp512707; Tue, 23 Apr 2002 11:49:51 -0400 Message-Id:<200204231549.g3NFnp512707@pcp259033pcs.howard01.md.comcast.net> Date: Tue, 23 Apr 2002 08:56:00 -0000 From: Ben Dorman To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version:3.113 Subject: c++/6426: gcc produces incorrect call to compiler generated copy ctor X-SW-Source: 2002-04/txt/msg01204.txt.bz2 List-Id: >Number: 6426 >Category: c++ >Synopsis: gcc produces incorrect call to compiler generated copy ctor >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: wrong-code >Submitter-Id: net >Arrival-Date: Tue Apr 23 08:56:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Ben Dorman >Release: 3.0.3 >Organization: >Environment: System: Linux pcp259033pcs.howard01.md.comcast.net 2.4.2-2 #1 Sun Apr 8 19:37:14 EDT 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc-3.0.3/configure --enable-threads --prefix=/usr >Description: g++ incorrectly generates call to compiler-generated copy ctor for exception >How-To-Repeat: consider following function: void FITS::open (RWmode mode) { //## begin CCfits::FITS::open%380B3C3FACA8.body preserve=yes // C code generates integer status flag int status = fits_open_file(&m_FITSImpl->fptr(), m_FITSImpl->name().c_str(), mode, &status); const std::string diag (m_FITSImpl->name()); bool silent = s_verboseMode; if (status != 0) { if (status == FILE_NOT_OPENED) throw CantOpen(diag,silent); else throw FitsError(status); } //## end CCfits::FITS::open%380B3C3FACA8.body } FITS::CantOpen is an exception class defined as follows: class CantOpen : public FitsException //## Inherits: %39C8EB1D02C0 { public: //## Constructors (specified) //## Operation: CantOpen%39C8E9FA01BA CantOpen (const string& diag, bool silent = false); explicit CantOpen(const CantOpen&); protected: private: private: //## implementation }; [note: the explicit copy ctor is not usually present in these declarations but is added here to demonstrate the problem] Compilation of the above file with the explicit keyword generates following output:- c++ -DHAVE_CONFIG_H -I. -I. -I. -I./.. -I/home/dorman/cpp/include -g -v -save-temps -Wall -c FITS.cxx Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/specs Configured with: ../gcc-3.0.3/configure --enable-threads --prefix=/usr Thread model: posix gcc version 3.0.3 /usr/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/cpp0 -lang-c++ -D__GNUG__=3 -D__GXX_DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -v -I. -I. -I. -I./.. -I/home/dorman/cpp/include -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=3 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -Wall -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ -DHAVE_CONFIG_H FITS.cxx FITS.ii GNU CPP version 3.0.3 (cpplib) (i386 Linux/ELF) ignoring nonexistent directory "/usr/i686-pc-linux-gnu/include" ignoring duplicate directory "." ignoring duplicate directory "." #include "..." search starts here: #include <...> search starts here: . .. /home/dorman/cpp/include /usr/include/g++-v3 /usr/include/g++-v3/i686-pc-linux-gnu /usr/include/g++-v3/backward /usr/local/include /usr/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/include /usr/include End of search list. /usr/lib/gcc-lib/i686-pc-linux-gnu/3.0.3/cc1plus -fpreprocessed FITS.ii -quiet -dumpbase FITS.cxx -g -Wall -version -o FITS.s GNU CPP version 3.0.3 (cpplib) (i386 Linux/ELF) GNU C++ version 3.0.3 (i686-pc-linux-gnu) compiled by GNU C version 3.0.3. FITS.cxx: In member function `void CCfits::FITS::open(CCfits::RWmode)': FITS.cxx:544: no matching function for call to `CCfits::FITS::CantOpen::CantOpen(CCfits::FITS::CantOpen)' FITS.cxx:104: candidates are: CCfits::FITS::CantOpen::CantOpen(const std::string&, bool = false) make: *** [FITS.o] Error 1 showing that the compiler wants to call the copy ctor, not the custom ctor despite a perfect match to argts. >Fix: Removing the 'explicit' keyword allows code to compile but exception handling may result in terminate() call instead of safe behaviour. >Release-Note: >Audit-Trail: >Unformatted: