473,508 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

typedefs, qualified identifiers, class names and name lookup

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
}
--
Unicals Group -- Development Tools for OEMs
http://www.unicals.com
Jan 13 '06 #1
0 1487

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3179
by: Brian Jones | last post by:
I'm sure the solution may be obvious, but this problem is driving me mad. The following is my code: class a(object): mastervar = def __init__(self): print 'called a'
1
1818
by: Markus Doering | last post by:
Hey, I am trying to process XML schema documents using namespace aware SAX handlers. Currently I am using the default python 2.3 parser: parser = xml.sax.make_parser()...
13
6103
by: copx | last post by:
Somehow I totally forgot how typedefs/structs work. Why doesn't this work: typedef struct _MY_STRUCT { int a; int b; struct _MY_STRUCT *c; } MY_STRUCT; My compiler complains about...
5
2997
by: fc2 | last post by:
Hi I have a problem with fully qualified names. According to the C# language specification: "Every namespace and type has a fully qualified name, which uniquely identifies the namespace or...
3
4473
by: pyramus | last post by:
I am wondering which one should be preferred for creating a local synonym within a function definition. Let's say I have a type in my library called MyLib::Foundation::int32, which I can't stand...
3
2213
by: aiooua | last post by:
Any idea why the following code does not compile? ---- #include<iostream> #include<list> using namespace std; class Base { public: int val;
4
2420
by: Wayne Shu | last post by:
Hey, guys. There is a problem. e.g. template <typename T> class foo { public: foo();
8
3340
by: Tim H | last post by:
I know C's rules about reserved identifiers (anything starting with "_", leading "is", etc). I don't know C++ rules. I assume the same rules and more apply? I've seen several conventions for...
399
12635
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
0
7231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5643
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3198
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
435
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.