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]

vtable


   It seems me there is a bug in egcs-1.01 and gcc-2.8.0.
        I have  maked the compiler with -DNOTQUITE flag.
        The differences in the output from the compilers are marked.


                                egcs-1.01 and gcc-2.8.0
                                -----------------------
Output Compiler:
x.cc:6: warning: Doing hard virtuals for desc...
x.cc:19: warning: Doing hard virtuals for xobj...
x.cc:25: warning: Doing hard virtuals for rBase...
x.cc:35: warning: Doing hard virtuals for tBase...
x.cc:35: warning: in tBase virtual table
x.cc:35: warning: replaced xobj::f(void) with tBase::f(void)
x.cc:50: warning: Doing hard virtuals for t<char>...
x.cc:50: warning: in t<char>::rBase virtual table
x.cc:50: warning: replaced rBase::c1(void) const with t<char>::c1(void)
const
x.cc:51: warning: Doing hard virtuals for t<int>...
x.cc:51: warning: in t<int>::rBase virtual table
x.cc:51: warning: replaced t<char>::c1(void) const with t<int>::c1(void)
const
                  ---------------------------------

x.cc:52: warning: Doing hard virtuals for t<long long int>...
x.cc:52: warning: in t<long long>::rBase virtual table
x.cc:52: warning: replaced t<int>::c1(void) const with t<long
long>::c1(void) const
x.cc:53: warning: Doing hard virtuals for msg...

Output Program:
---------------
void xobj::f1()
void tBase::f()
void t<long long int>::c1() const:sizeof(T)=8
void tBase::f()
void t<long long int>::c1() const:sizeof(T)=8
void tBase::f()
void t<long long int>::c1() const:sizeof(T)=8
----------------------------------------------------------------

                                gcc-2.7.2.3
                                -----------
Output Compiler:
x.cc:6: warning: Doing hard virtuals for desc...
x.cc:19: warning: Doing hard virtuals for xobj...
x.cc:25: warning: Doing hard virtuals for rBase...
x.cc:35: warning: Doing hard virtuals for tBase...
x.cc:35: warning: in tBase virtual table
x.cc:35: warning: replaced xobj::f(void) with tBase::f(void)
x.cc:45: warning: Doing hard virtuals for t<char>...
x.cc:45: warning: in t<char>::rBase virtual table
x.cc:45: warning: replaced rBase::c1(void) const with t<char>::c1(void)
const
x.cc:45: warning: Doing hard virtuals for t<int>...
x.cc:45: warning: in t<int>::rBase virtual table
x.cc:45: warning: replaced rBase::c1(void) const with t<int>::c1(void)
const
                  -------------------------
x.cc:45: warning: Doing hard virtuals for t<long long int>...
x.cc:45: warning: in t<long long>::rBase virtual table
x.cc:45: warning: replaced rBase::c1(void) const with t<long
long>::c1(void) const
x.cc:53: warning: Doing hard virtuals for msg...

Output Program:  OK
void xobj::f1()
void tBase::f()
void t<char>::c1() const
void tBase::f()
void t<int>::c1() const
void tBase::f()
void t<long long int>::c1() const


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


The testprogram(sorry shorter is not possible for me):
----------------
If I change in the marked line 'xobj' with 'rBase' then all is ok.
Then the  Output is the same as with gcc-2.7.2.3
What role play this?

#include <stdio.h>

class xobj;
struct desc {
        xobj xobj::* mp;
};
extern desc tab[];

class xobj
{
public:
        virtual void f(){ printf("%s\n", __PRETTY_FUNCTION__); }
        void f1() {
                printf("%s\n", __PRETTY_FUNCTION__);
                ( & ( this ->* tab[ 0 ].mp ) ) ->f();
                ( & ( this ->* tab[ 1 ].mp ) ) ->f();
                ( & ( this ->* tab[ 2 ].mp ) ) ->f();
        }
};

class rBase
{
public:
        virtual void  c1() const = 0;
};

                                          //----------------
class tBase : public xobj , public rBase  //  <<---- here
{                                         //-----------------
        public:
        virtual void f(){
                tBase *q= this;
                printf("%s\n", __PRETTY_FUNCTION__);
                q->c1();
        }
};

template <class T>
class t : public tBase
{
public:
        virtual void c1() const
        {
                printf("%s:sizeof(T)=%d\n",
__PRETTY_FUNCTION__,sizeof(T));
        }
};

class msg : public xobj
{
  public:
        t<char> A;
        t<int>  B;
        t<long long> C;
};

desc tab[] = {
 { (xobj (xobj::*))&msg::A},
 { (xobj (xobj::*))&msg::B},
 { (xobj (xobj::*))&msg::C}
};

void main()
{
        msg  m;
        m.f1();
}





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