public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/6426: gcc produces incorrect call to compiler generated copy ctor
@ 2002-04-23  8:56 Ben Dorman
  0 siblings, 0 replies; 3+ messages in thread
From: Ben Dorman @ 2002-04-23  8:56 UTC (permalink / raw)
  To: gcc-gnats


>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: <unnamed>%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:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/6426: gcc produces incorrect call to compiler generated copy ctor
@ 2002-04-24  9:36 rodrigc
  0 siblings, 0 replies; 3+ messages in thread
From: rodrigc @ 2002-04-24  9:36 UTC (permalink / raw)
  To: dorman, gcc-bugs, gcc-prs, nobody

Synopsis: gcc produces incorrect call to compiler generated copy ctor

State-Changed-From-To: feedback->closed
State-Changed-By: rodrigc
State-Changed-When: Wed Apr 24 09:36:56 2002
State-Changed-Why:
    Preprocessed source submitted in PR 6427.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6426


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/6426: gcc produces incorrect call to compiler generated copy ctor
@ 2002-04-23 18:15 rodrigc
  0 siblings, 0 replies; 3+ messages in thread
From: rodrigc @ 2002-04-23 18:15 UTC (permalink / raw)
  To: dorman, gcc-bugs, gcc-prs, nobody

Synopsis: gcc produces incorrect call to compiler generated copy ctor

State-Changed-From-To: open->feedback
State-Changed-By: rodrigc
State-Changed-When: Tue Apr 23 18:15:39 2002
State-Changed-Why:
    Submit a complete testcase (preprocessed source) as outlined
    in http://gcc.gnu.org/bugs.html and not just a code snippet.
    The information you gave is not enough to evaluate the problem.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6426


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-04-24 16:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-23  8:56 c++/6426: gcc produces incorrect call to compiler generated copy ctor Ben Dorman
2002-04-23 18:15 rodrigc
2002-04-24  9:36 rodrigc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).