delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/05/24/06:45:55

Date: Fri, 24 May 2002 12:45:33 +0200 (MEST)
From: ahelm AT gmx DOT net
To: djgpp AT delorie DOT com
MIME-Version: 1.0
Subject: GCC v3.1 problem with implicit copy constuctor
X-Priority: 3 (Normal)
X-Authenticated-Sender: #0003579562 AT gmx DOT net
X-Authenticated-IP: [194.201.128.5]
Message-ID: <5886.1022237133@www22.gmx.net>
X-Mailer: WWW-Mail 1.5 (Global Message Exchange)
X-Flags: 0001
Reply-To: djgpp AT delorie DOT com

Hi,

I'm having trouble compiling the code below with GCC v3.1
under DJGPP. I currently have no other systems available
(with v3.1) so I would like to ask DJGPP folks first before 
posting this on a GCC mailing list.
The code compiles nicely with all other versions of GCC I have
here (2.95.2, 2.95.3 3.0.2, 3.0.3, 3.0.4).
I'm not so fluent with the C++ standard, so there might be something
wrong with the code. The code given here doesn't actually do
anything useful, but this is more or less the shortest example
that shows this problem which I got out of a much more complex
program.

Any ideas welcome.

Regards,

Tony

a.cpp: In copy constructor `QQ::QQ(const QQ&)':
a.cpp:57: invalid conversion from `const RR*' to `long long int'
a.cpp:57:   initializing argument 1 of `RR::RR(long long int)'
a.cpp: In function `int main()':
a.cpp:57:   initializing temporary from result of `QQ::QQ(const RR&)'

// begin test code
class QQ;

class RR
{ 
public:
  short xx;
        RR(const long long i);
        RR();
        RR(const RR& f);
        ~RR();
};

class QQ
{
public:
  RR    yy[4][4];
        QQ();
        QQ(const RR& f);
        ~QQ();
};

inline RR::RR(const long long i)
{
  yy = (short)i;
}

inline RR::RR() {yy = 0;}
inline RR::RR(const RR& f) {yy = f.xx;}
inline RR::~RR() {}

inline QQ::QQ()
{
  for(int i=0;i<4;i++)
  {
    for(int j=0;j<4;j++)
    {
      yy[i][j] = 0;
    }
  }
}

inline QQ::QQ(const RR &f)
{
  for(int i=0;i<4;i++)
  {
    for(int j=0;j<4;j++)
    {
      yy[i][j] = f;
    }
  }
}

inline QQ::~QQ(){}

int main()
{
  QQ x  = RR(123);
  QQ *y = &x;
  QQ z  = *y;

  return x.yy[3][3].xx;
}

// End test code

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019