This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13446] New: gcc uses cast operator when constructing an unnamed instance
- From: "erich_guenther at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Dec 2003 14:55:53 -0000
- Subject: [Bug c++/13446] New: gcc uses cast operator when constructing an unnamed instance
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#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