gcc-2.95.1: problem calling destructor on typedef of int within a namespace

Thomas, Paul D paul.thomas@eds.com
Wed Oct 20 04:01:00 GMT 1999


When I compile this code fragment using gcc 2.95.1:

namespace A {typedef int Z;}
int main(void)
{
    A::Z* z;
    z->A::Z::~Z(); //error
}

The following error is reported...

In function 'int main()':
5: qualified type 'int' does not match destructor name '~Z'

The strange thing is that if I include the typedef line
twice, gcc++ compiles the code without any problem. e.g.

namespace A {typedef int Z;}
namespace A {typedef int Z;}
int main(void)
{
    A::Z* z;
    z->A::Z::~Z(); //okay
}

or

namespace A {typedef int Z; typedef int Z;}
int main(void)
{
    A::Z* z;
    z->A::Z::~Z(); //okay
}

This looks like a bug in g++ to me particularly as there is a
very similar code fragment in section 3.4.3 (5) of the  C++
Draft Standard (2 Dec 96) which looks like this...

struct A {
typedef int I;
};
typedef int I1, I2;
extern int* p;
extern int* q;
p->A::I::~I();  // I is looked up in the scope of A
q->I1::~I2();   // I2 is looked up in the scope of
                // the postfix-expression

If I add a main around this code so that it looks like this...

struct A {
typedef int I;
};
int main(void)
{
    typedef int I1, I2;
    extern int* p;
    extern int* q;
    p->A::I::~I(); // I is looked up in the scope of A
    q->I1::~I2(); // I2 is looked up in the scope of
                  // the postfix-expression
}

gcc 2.95.1 reports the following error which is the same as
the error reported on my code fragment above:

In function 'int main()':
9: qualified type 'int' does not match destructor name '~I'

--
Paul Thomas
paul.thomas@eds.com

                      


More information about the Gcc-bugs mailing list