473,503 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Visual C++ bug report

I think I have found a bug in the Visual C++ compiler (version 7.1). What is
the preferred way for reporting it to Microsoft? Here's a brief description
of the suspect behavior: the expression typeid(A)==typeid(B) evaluates to
true when A and B are instances of two different unnamed classes, even
though it should evaluate to false. This only happens when A and B are
defined at namespace scope. Example:
#include <typeinfo>
#include <iostream>

class { int x; } A;
class { double x; } B;

int main()
{
std::cout << (typeid(A) == typeid(B)) << std::endl;
return 0;
}
The above code prints "1" to stdout while it should print "0" instead
because A and B are instances of two different types.

Cheers,
Marco
Jan 31 '06 #1
9 1147
Strange. Works correctly for me.

Brian

"Marco Jez" <gu***@none.it> wrote in message
news:43**********************@reader3.news.tin.it. ..
I think I have found a bug in the Visual C++ compiler (version 7.1). What
is the preferred way for reporting it to Microsoft? Here's a brief
description of the suspect behavior: the expression typeid(A)==typeid(B)
evaluates to true when A and B are instances of two different unnamed
classes, even though it should evaluate to false. This only happens when A
and B are defined at namespace scope. Example:
#include <typeinfo>
#include <iostream>

class { int x; } A;
class { double x; } B;

int main()
{
std::cout << (typeid(A) == typeid(B)) << std::endl;
return 0;
}
The above code prints "1" to stdout while it should print "0" instead
because A and B are instances of two different types.

Cheers,
Marco

Jan 31 '06 #2
Hi Marco!
I think I have found a bug in the Visual C++ compiler (version 7.1). What is
the preferred way for reporting it to Microsoft?


It seems that this is still abug in VS2005...
At least for me it displays "1"

You should report the bug on ladybug:
http://lab.msdn.microsoft.com/produc...k/default.aspx

Then please post here the link to the new bug, so we can vote for it or
validate it...
--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jan 31 '06 #3
global scope is not required. they just have to be in the same namespace.
if you put them in namepace bla it has the same result.

std::cout << typeid(A).name() << std::endl;
std::cout << typeid(B).name() << std::endl;

you 'll see 2 times 'bla::__unnamed'

which is caused by the fact that your classes don't have class names.
the funny thing is that intellisense shows __unnamed_c609b043_1 for A and
__unnamed_c609b043_2 for B, so i'm surprised that they have the same
typeids.

that being said, i don't know if the behavior in this case is defined or
not.
the safest thing to do is to provide tag names.

kind regards,
Bruno.
"Marco Jez" <gu***@none.it> wrote in message
news:43**********************@reader3.news.tin.it. ..
I think I have found a bug in the Visual C++ compiler (version 7.1). What
is the preferred way for reporting it to Microsoft? Here's a brief
description of the suspect behavior: the expression typeid(A)==typeid(B)
evaluates to true when A and B are instances of two different unnamed
classes, even though it should evaluate to false. This only happens when A
and B are defined at namespace scope. Example:
#include <typeinfo>
#include <iostream>

class { int x; } A;
class { double x; } B;

int main()
{
std::cout << (typeid(A) == typeid(B)) << std::endl;
return 0;
}
The above code prints "1" to stdout while it should print "0" instead
because A and B are instances of two different types.

Cheers,
Marco

Jan 31 '06 #4
slap forehead... Bruno's right.

Brian
Jan 31 '06 #5
> It seems that this is still abug in VS2005...
At least for me it displays "1"

You should report the bug on ladybug:
http://lab.msdn.microsoft.com/produc...k/default.aspx


Thanks, Jochen, I've submitted the bug report. You can find it here:
http://lab.msdn.microsoft.com/Produc...9-336957032e32

Cheers,
Marco
Jan 31 '06 #6
Hi Bruno,
global scope is not required. they just have to be in the same namespace.
if you put them in namepace bla it has the same result.
I didn't say "global scope", I said "namespace scope"... :-)
that being said, i don't know if the behavior in this case is defined or
not.
the safest thing to do is to provide tag names.


The C++ Standard is pretty clear in explaining what you should expect from
the typeid operator, and unnamed classes are not mentioned as a particular
condition to be aware of. The paragraph that can be applied to my example is
the following:

"When typeid is applied to an expression other than an lvalue of a
polymorphic class type, the result refers to a type_info object representing
the static type of the expression. "

Unless I'm not misinterpreting that, the Standard states that typeid(A)
returns a type_info representing the static type of A, and typeid(B) returns
a type_info representing the static type of B. In my example the static type
of A is clearly different from that of B, but the two type_info objects
result to be equal (or at least indistinguishible one from the other), and
that's a violation of the above statement.

As for using tag names I agree with you, but I'm writing a
reflection/introspection framework, so being unable to distinguish between
two different types is a heavy deficiency for my project. I personally avoid
using unnamed classes, but the library I'm writing must exhibit consistent
behavior when used with foreign code I have no control on. :-/

Cheers,
Marco
Jan 31 '06 #7
Marco Jez wrote:
It seems that this is still abug in VS2005...
At least for me it displays "1"

You should report the bug on ladybug:
http://lab.msdn.microsoft.com/produc...k/default.aspx


Thanks, Jochen, I've submitted the bug report. You can find it here:
http://lab.msdn.microsoft.com/Produc...9-336957032e32


Validated and voted on. Thanks for taking the time to submit the report!

-cd
Feb 1 '06 #8
Hi Marco!
It seems that this is still abug in VS2005...
At least for me it displays "1"

You should report the bug on ladybug:
http://lab.msdn.microsoft.com/produc...k/default.aspx


Thanks, Jochen, I've submitted the bug report. You can find it here:
http://lab.msdn.microsoft.com/Produc...9-336957032e32


Thanks for submitting the bug-report! I Validated and voted for it...

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Feb 1 '06 #9
I didn't say "global scope", I said "namespace scope"... :-) my mistake.

anyway I validated and voted.

kind regards,
Bruno.

that being said, i don't know if the behavior in this case is defined or
not.
the safest thing to do is to provide tag names.


The C++ Standard is pretty clear in explaining what you should expect from
the typeid operator, and unnamed classes are not mentioned as a particular
condition to be aware of. The paragraph that can be applied to my example is
the following:

"When typeid is applied to an expression other than an lvalue of a
polymorphic class type, the result refers to a type_info object representing
the static type of the expression. "

Unless I'm not misinterpreting that, the Standard states that typeid(A)
returns a type_info representing the static type of A, and typeid(B) returns
a type_info representing the static type of B. In my example the static type
of A is clearly different from that of B, but the two type_info objects
result to be equal (or at least indistinguishible one from the other), and
that's a violation of the above statement.

As for using tag names I agree with you, but I'm writing a
reflection/introspection framework, so being unable to distinguish between
two different types is a heavy deficiency for my project. I personally avoid
using unnamed classes, but the library I'm writing must exhibit consistent
behavior when used with foreign code I have no control on. :-/

Cheers,
Marco

Feb 1 '06 #10

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

Similar topics

1
2150
by: Corrie Meyer | last post by:
Announcement: SwiftReports standard edition 1.0 for Visual Studio ..NET 2003 released by UniSwift. We are pleased to announce the first release of a fully-managed reporting tool for the...
2
2354
by: GC | last post by:
HI, I'am using Crystal Report with visual Studio .NEt 2003 When i make a report using a store procedure, I can not see all the fields of the store proc and i'm suppose to see those fields. I'm...
6
2052
by: Greg Teets | last post by:
I am new to VB and Access reports. Is it correct to say that VB and Access have the same report engine or method? After I do all the dragging and dropping, is there a way to see the specs for...
8
4321
by: Rod | last post by:
I've written a Visual Studio .NET application (WinForms app) and put a Crystal Reports for .NET report in it. It is a very simple application - one regular form and another with the crystal...
1
1435
by: ad | last post by:
I can find Cristal Report in Visual Web Developer 2005 Express. How can I do with Cristal Report in Visual Web Developer 2005 Express ?
1
2225
by: Kannan | last post by:
Hi, I have noticed that Visual studio 2005 coming along with Crystal report. I have few crystal reports which is developed in 6.0 in my existing VB project and currently we are migrating m y VB...
2
2071
by: CAM | last post by:
Hello, I am wondering if someone can give me some pointers. Currently I am using Access 2002 I developed an inventory tracking database, which this database is used in California and in...
0
1355
by: ranesmitas | last post by:
i want to use crystal report in visual basic as i am new , i want to know i create crytal report in visual basic . we want to create designer (crystal report) in visual basic or in seagate crystal...
1
2238
by: =?Utf-8?B?Y2hhaXJtYW4=?= | last post by:
I am trying to set up a Report Server to publish reports that I have created in Visual Studio 2005. I have been able to get it up and running and I am able to access reports via the web and set up...
3
3036
by: firozfasilan | last post by:
I am new to visual basic 2008. In the past I have used vb6 to display an existing crystal report. I would like to accomplish the same with vb.net. However I am not clear on the syntax to display a...
0
7074
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
7273
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,...
1
6982
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
5572
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
5000
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
4667
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
3161
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
374
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.