Archived

This topic is now archived and is closed to further replies.

MuLuX

VC++ 6.0 Bug?

Recommended Posts

I dunno but I think I've found a bug in VC++ 6.0, try this:
#include <iostream>
using namespace std;

class A {
public:
	static void Print() { cout << "A" << endl; }
};

class B {
public:
	static void Print() { cout << "B" << endl; }
};

// Buggy template function
template{typename T}
void TPrint()
{
	T:rint();
}

// Template function with "template argument" in function head, not buggy.
template{typename T}
void TPrint2(T* p = 0)
{
	T:rint();
}

int main()
{
	TPrint{A}();
	TPrint{b}();
	TPrint2{A}();
	TPrint2{b}();
	return 0;
}
  
(Replace my {} tags with the correct tags, forum wouldn't allow me to post them.) Output is: B B A B Should be: A B A B Correct me if I'm wrong. [edited by - MuLuX on January 30, 2003 2:56:59 AM]

Share this post


Link to post
Share on other sites
MSVC 6.0 had (has) major problems with templates. That looks like something it''d do.

If you''re willing to try something new (for free), GCC has very good template support (3.x especially, although 2.95.x had good support too).

Share this post


Link to post
Share on other sites
Oh yeah, btw, I'm running linux on my server and sometimes I compile myu stuff there to make sure it's Linux compalitable, anyways I had a problem with anonymous structures in classes some time ago. I'm running gcc 2.95.something
Here's what I was trying to do:

class CVector {
public:
union {
float v[3];
struct {
float x, y, z;
};
};
};

This gave me some kind of error, don't remeber exactly what it said. I dunno if this is a bug but I think anonymous structs/unions are part of the C++ standard, right? Anyways is there anyway to come around this problem?

[edited by - MuLuX on January 30, 2003 4:01:59 AM]

Share this post


Link to post
Share on other sites
Some versions of GCC supported the ''down-scoping'' of anonymous unions, but none supported the ''down-scoping'' of anonymous structures as far as I know.

I don''t think GCC''s 3.x''s C and C++ compilers support either (3.x cut many of the old GCC extensions to C and C++).

There might be a command line switch or pragma to enable those extensions though (I know Borland has a pragma to do that, for instance).

Share this post


Link to post
Share on other sites