Topic: typedefs, qualified identifiers, class names and name lookup
Author: "Ivan A. Kosarev" <ikosarev@online.ru>
Date: Tue, 10 Jan 2006 15:06:31 CST Raw View
Hello,
There is 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
}
--
Unicals Group -- Development Tools for OEMs
http://www.unicals.com
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]