This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13446] New: gcc uses cast operator when constructing an unnamed instance


#define FAILS
/* gcc (GCC) 3.3 20030226 (prerelease) (SuSE Linux)
tst.cpp: In constructor `CB::CB()':
tst.cpp:16: error: `SData::operator CDataAccessor&()' is inaccessible
tst.cpp:46: error: within this context
*/
struct CDataAccessor;

// Data layout only
struct SData
{
	int m_x;
#ifdef FAILS
	operator const CDataAccessor &() const
	{
		return * reinterpret_cast<const CDataAccessor *>(this);
	}
#endif
};

// Accessor class
class CDataAccessor: protected SData
{
public:
	explicit CDataAccessor(int i)
	{
		m_x=i;
	};

	int Getx() const
	{
		return m_x;
	}
};

class CA
{
public:
	CA(int i, const CDataAccessor& x);
};

class CB: public CA
{
public:
	CB():CA(2, CDataAccessor(3))
	{
	};
};


void foo()
{
	CB b;
}

-- 
           Summary: gcc uses cast operator when constructing an unnamed
                    instance
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: erich_guenther at hotmail dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]