typedefs, qualified identifiers, class names and name lookup

I

Ivan A. Kosarev

Hello,

There are three similar programs below. All of these use typedef names,
qualified identifiers, class names and name lookup mechanism in various
contexts. I found that most respect C++ compilers differ significantly in
interpreting the code. So, could anyone pick a correct behavior a conformant
compiler should follow for each of the cases?

Please note that I used the following compilers and command-line options:

EDG 3.6 --strict
MSVC 13.10.3077 /Za
GCC 3.4.4 --ansi

Thank you.

// 1
class C {
public:
int f();
};

int main() {
typedef C T;
C c;

// EDG MSVC GCC
c.~T(); // ok ok ok
c.T::~T(); // ok ok ok
c.T::C::f(); // ok fails ok
c.T::T::f(); // fails fails fails
}

// 2
class C {
public:
typedef int T;
int f();
};

int main() {
typedef C T;
C c;

// EDG MSVC GCC
c.~T(); // ok ok fails
c.T::~T(); // ok fails fails
c.T::C::f(); // ok fails fails
c.T::T::f(); // fails fails fails
}


// 3
class T {
public:
int f();
};

class C : public T {
public:
typedef int T;
};

int main() {
typedef C T;
C c;

// EDG MSVC GCC
c.~T(); // ok ok fails
c.T::~T(); // fails ok fails
c.T::C::f(); // fails fails fails
c.T::T::f(); // fails fails fails
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top