473,395 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

VC++ bug or not?

This code works fine with gcc 3.x and 4.0, but generates odd compile
time errors with VC++ 2003 .NET. Is there something subtle that's wrong
with it, or is it just a compiler bug?

struct A {
static const char c = 'A';
};

struct B : public A {
static const char c = 'B';
typedef A PARENT;
};

struct C : public B {
static const char c = 'C';
typedef B PARENT;
};

main()
{
cout << C::c;
cout << C::PARENT::c;
cout << C::PARENT::PARENT::c;
return 0;
}

For some reason, the compiler is unable to resolve the line of code
that attempts to root back through two typedefs to the base class A. It
tells me that "__ctor is not a member of B".

Jul 23 '05 #1
5 1398
<sn********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com
This code works fine with gcc 3.x and 4.0, but generates odd compile
time errors with VC++ 2003 .NET. Is there something subtle that's
wrong with it, or is it just a compiler bug?

struct A {
static const char c = 'A';
};

struct B : public A {
static const char c = 'B';
typedef A PARENT;
};

struct C : public B {
static const char c = 'C';
typedef B PARENT;
};

main()
{
cout << C::c;
cout << C::PARENT::c;
cout << C::PARENT::PARENT::c;
return 0;
}

For some reason, the compiler is unable to resolve the line of code
that attempts to root back through two typedefs to the base class A.
It tells me that "__ctor is not a member of B".


VC++2005 beta 2 compiles and executes the code without a problem. Comeau
also accepts it. Appears to be a bug.

--
John Carson

Jul 23 '05 #2
sn********@gmail.com wrote:
This code works fine with gcc 3.x and 4.0, but generates odd compile
time errors with VC++ 2003 .NET. Is there something subtle that's wrong
with it, or is it just a compiler bug?

struct A {
static const char c = 'A';
};

struct B : public A {
static const char c = 'B';
typedef A PARENT;
};

struct C : public B {
static const char c = 'C';
typedef B PARENT;
};

main()
Aside from the missing #include and 'using', and the return value type
of the 'main', there is nothing wrong with it.
{
cout << C::c;
cout << C::PARENT::c;
cout << C::PARENT::PARENT::c;
return 0;
}

For some reason, the compiler is unable to resolve the line of code
that attempts to root back through two typedefs to the base class A. It
tells me that "__ctor is not a member of B".


It's a bug. You might want to check with 'microsoft.public.vc.language'
to see if folks who use those compilers the most, know anything about it
or to see how to check if Microsoft knows about it. FWIW, VC++ 2005 Beta
doesn't compile it either.

BTW, all 'c' static consts have to be defined outside the respective class
definitions since they are used elsewhere in the program (in 'main').

V
Jul 23 '05 #3
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Ij******************@newsread1.mlpsca01.us.to .verio.net
sn********@gmail.com wrote:
It's a bug. You might want to check with

'microsoft.public.vc.language' to see if folks who use those
compilers the most, know anything about it or to see how to check if
Microsoft knows about it. FWIW, VC++ 2005 Beta doesn't compile it
either.


Beta 1? Beta 2 handles it without a problem.

--
John Carson

Jul 23 '05 #4
John Carson wrote:
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Ij******************@newsread1.mlpsca01.us.to .verio.net
sn********@gmail.com wrote:
It's a bug. You might want to check with
'microsoft.public.vc.language' to see if folks who use those
compilers the most, know anything about it or to see how to check if
Microsoft knows about it. FWIW, VC++ 2005 Beta doesn't compile it
either.

Beta 1?


Yes.
Beta 2 handles it without a problem.


Good. I keep forgetting to mention '1'.

V
Jul 23 '05 #5
Thanks all.. If it's fixed in Beta 2 I suspect the chances of any fix
in 2003 .NET are nil. I was mostly concerned that I was up against
personal ignorance of some standard scoping rules and was making a
gaffe.

I'll check the vc newsgroup for vendor-specific info.

|
| Mark Nelson markn at ieee.org
|

Jul 23 '05 #6

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

Similar topics

11
by: Tatu Portin | last post by:
Have this kind of struct: typedef struct { char **user_comments; /* ... */ } vorbis_comment; /* prototype */ char * read_vorbis_string ( FILE *sc);
4
by: Anthony Gallagher | last post by:
I have a bunch of libraries compiled using VC++ 6.0, and I am trying to recompile one of our projects using VC++ .NET. I get all kind of linker errors (specially in STL calls). How do I get rid of...
5
by: Hari | last post by:
Guys please help me to solve this strange problem what Iam getting as follows.. Trying to instantiate a global instance of a template class as follows :- when i build this code with debug and...
2
by: vemulakiran | last post by:
Hi all, I have doubt regarding .NET. I have a tool which was developed on VC++ 6.0(Win32 Application ). The application communicates with library (API) which was developed on VC++ 6.0 called core...
2
by: | last post by:
Everything seems to be moving to .NET and VC++ seems to be adding a lot of managed code support every new release. The questions: is unmanaged code in VC++ beeing phased out in favour of managed...
4
by: ultranet | last post by:
I have cruised around http://msdn.microsoft.com/visualc/ and the rest of the site, and i am not able to find a single C++ or VC++ certification exam that will be available after June 30, 2004. I...
1
by: Steve | last post by:
We are considering the ways to migrate our VC++ 6.0 applications to .NET platform. It would be nice to rewrite them completely in C#, but due to the time constraints this option is out of...
2
by: um | last post by:
When the POSIX pthreads library for w32 release 2-2-0 (http://sources.redhat.com/pthreads-win32/) is compiled with VC++6 then it compiles and passes all the benchmark tests in the subdirectory...
15
by: Michael Tissington | last post by:
I have a Visual Basic 6.0 ActiveX Control. It seems there is no way with VS 2005 to create a similar control for containers that host ActiverX controls, is this correct ? I'm thinking of...
7
by: Norman Diamond | last post by:
A project depends on VC runtime from Visual Studio 2005 SP1, and DotNet Framework 2. Options are set in the setup project properties, so if these two dependencies are not already installed then...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.