[Bug c++/12491] New: Destructor fails to compile when optimizations (inlining) are enabled

harizak at speech dot gr gcc-bugzilla@gcc.gnu.org
Thu Oct 2 11:36:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12491

           Summary: Destructor fails to compile when optimizations
                    (inlining) are enabled
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: harizak at speech dot gr
                CC: gcc-bugs at gcc dot gnu dot org,harizak at speech dot gr
 GCC build triplet: i386-pc-solaris2.8
  GCC host triplet: i386-pc-solaris2.8
GCC target triplet: i386-pc-solaris2.8

Problem description
===================

  The compiler failes to compile the destructor of the Error class (see below)
when its body is outside of the class definition and inlining is turned on.
Moving the body within the Error class definition makes the error disappear. 

  Turning of inlining using the -fno-inline switch solves the problem. The
problem is also solved by disabling optimizations by using either -O0 or
omitting the -O2.

  Best regards,

  Costas

P.S. Keep up the great work.


System description
==================

  The g++ used is the 3.3.1 configured with the following command on a Intel
Solaris 2.8 system:

./configure --prefix=<pathname> --enable-threads --enable-languages=c,c++,java
--disable-nls

Thread model: posix


How to reproduce the error
==========================

  The example can be successfully compiled with:

g++ <filename> -c -O2 -fno-inline

  But fails when the following is used:

g++ <filename> -c -O2


Example file producing error (after dashed line)
================================================


---------------------------------------------------------------

class Object
{
public:
	virtual ~Object (void)
		{ return; }
};


class AutoPtr
{
public:
	~AutoPtr (void)
		{ delete m_rep; return; }

private:
        const Object*   m_rep;

};


class Handle
{
public:
	~Handle	(void)
		{ return; }

private:
	AutoPtr		m_rep;

};


class HandleOf : public Handle
{
public:
	~HandleOf (void)
		{ return; }
};


class Error
{
public:
	~Error (void);

private:
	HandleOf	m_hndl;
};


Error::~Error (void)
{
	return;
}


---------------------------------------------------------------



More information about the Gcc-bugs mailing list