473,668 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A VC8 bug£¿

the programme is as follows
#include <iostream>
using namespace std;

void f( const char*p){cout<<" const char * "<<p<<endl; }
void f( char*p){cout<<" char * "<<p<<endl; }

int main()
{
f("hello");

try{
throw "hello";
}catch(char *p){
cout<<"char * "<<p<<endl;
}catch(const char *p){
cout<<"const char * "<<p<<endl;
}
}
in VC8 it's output is:
const char * hello
char * hello

I don't think it's a corrent answer, since "hello" has a type of "const
char*".then I change to the Intel CPP Compiler 9.the result is :
const char * hello
const char * hello

so it's a VC8's bug? But it seems impossible that vc8 does such a
stupid mistake.

Nov 28 '06 #1
4 1424
mi*********@gma il.com wrote:
the programme is as follows
#include <iostream>
using namespace std;

void f( const char*p){cout<<" const char * "<<p<<endl; }
void f( char*p){cout<<" char * "<<p<<endl; }

int main()
{
f("hello");

try{
throw "hello";
}catch(char *p){
cout<<"char * "<<p<<endl;
}catch(const char *p){
cout<<"const char * "<<p<<endl;
}
}
in VC8 it's output is:
const char * hello
char * hello

I don't think it's a corrent answer, since "hello" has a type of "const
char*".then I change to the Intel CPP Compiler 9.the result is :
const char * hello
const char * hello

so it's a VC8's bug? But it seems impossible that vc8 does such a
stupid mistake.
Changing the order of the catch statements results in the VC8 saying this:

xxcharp.cpp
xxcharp.cpp(15) : error C2312: 'char *' : is caught by 'const char *' on
line 13

Changing the caught pointers to pointer references also results in the
same error message.

gcc 3.4.4 behaves how you would expect.

I don't have a copy of the standard with me so I can't tell if it's
conforming but I would guess that VC8 is broken.

Nov 28 '06 #2

mi*********@gma il.com skrev:
the programme is as follows
#include <iostream>
using namespace std;

void f( const char*p){cout<<" const char * "<<p<<endl; }
void f( char*p){cout<<" char * "<<p<<endl; }

int main()
{
f("hello");

try{
throw "hello";
}catch(char *p){
cout<<"char * "<<p<<endl;
}catch(const char *p){
cout<<"const char * "<<p<<endl;
}
}
in VC8 it's output is:
const char * hello
char * hello

I don't think it's a corrent answer, since "hello" has a type of "const
char*".then I change to the Intel CPP Compiler 9.the result is :
const char * hello
const char * hello

so it's a VC8's bug? But it seems impossible that vc8 does such a
stupid mistake.
I believe that this is related to the standards requirement that
implicitly casts away const on char* (allowing common legacy code such
as char* test = "hello" to compile), that kicks in.
It requires a language lawyer to resolve with greater confidence,
however. If noone pops up here, I recommend you to take it to
comp.lang.c++.m oderated.

/Peter

Nov 28 '06 #3
peter koch wrote:
mi*********@gma il.com skrev:
....
>so it's a VC8's bug? But it seems impossible that vc8 does such a
stupid mistake.

I believe that this is related to the standards requirement that
implicitly casts away const on char* (allowing common legacy code such
as char* test = "hello" to compile), that kicks in.
It requires a language lawyer to resolve with greater confidence,
however. If noone pops up here, I recommend you to take it to
comp.lang.c++.m oderated.
That's only for string literals. In this case the VC8 compiler has the
same error when thowing a "const char *" value;
Nov 28 '06 #4

Gianni Mariani skrev:
peter koch wrote:
mi*********@gma il.com skrev:
...
so it's a VC8's bug? But it seems impossible that vc8 does such a
stupid mistake.
I believe that this is related to the standards requirement that
implicitly casts away const on char* (allowing common legacy code such
as char* test = "hello" to compile), that kicks in.
It requires a language lawyer to resolve with greater confidence,
however. If noone pops up here, I recommend you to take it to
comp.lang.c++.m oderated.

That's only for string literals.
Right. I should have mentioned that to be specific. But it is a string
literal that was thrown, and I guess that type might decay to char* as
well.
In this case the VC8 compiler has the
same error when thowing a "const char *" value;
Okay. Then its not it. One more bug in VC8. I wonder why I never had
any problems with that compiler.

/Peter

Nov 28 '06 #5

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

Similar topics

7
2205
by: delerious | last post by:
I just found a bug that's related to positioning in IE 5.5 (could someone please tell me if this bug exists in IE 6, and if so, if my solution works in that browser?). I don't know if this bug has been reported before, but here it is, and its solution, in case anyone else runs into it. On the following page there is a box (DIV) that contains six anchors. The anchors have a style of display:block, so you should be able to move the mouse...
5
7227
by: K. Shier | last post by:
when attempting to edit code in a class file, i see the bug "Visual Basic ..NET compiler is unable to recover from the following error: System Error &Hc0000005&(Visual Basic internal compiler error) Save your work and restart Visual Studio .NET." has anyone seen this bug and can you confirm one way or the other whether or not it can corrupt your source files? (by 'corrupt' i mean: do anything to it that will cause it to fail to load and...
102
7039
by: Xah Lee | last post by:
i had the pleasure to read the PHP's manual today. http://www.php.net/manual/en/ although Pretty Home Page is another criminal hack of the unix lineage, but if we are here to judge the quality of its documentation, it is a impeccability. it has or possesses properties of:
16
1726
by: Edward Diener | last post by:
After spending more than a day reducing a complicated compiler bug to a simple case I reported it to the MSDN Product Feedback Center as a bug just now. However this bug is completely stymying my development of a VC++ component. Does Microsoft still offer any free bug reporting cases for VS2005, as they did two for VS2003 so that I can talk with a technical representative directly to try to find a workaround for the compiler bug ? While...
26
2136
by: Patient Guy | last post by:
The code below shows the familiar way of restricting a function to be a method of a constructed object: function aConstructor(arg) { if (typeof(arg) == "undefined") return (null); this.property1 = arg; this.property2 = aConstantDefinedGlobally; this.method1 = function (anArg) {
158
6366
by: Giovanni Bajo | last post by:
Hello, I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the "PSF infrastracture committee", after weeks of evaluation, recommends using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell "Bitkeeper fiasco" to anyone else than me? --
8
2047
by: gw7rib | last post by:
I've been bitten twice now by the same bug, and so I thought I would draw it to people's attention to try to save others the problems I've had. The bug arises when you copy code from a destructor to use elsewhere. For example, suppose you have a class Note. This class stores some text, as a linked list of lines of text. The destructor runs as follows: Note::~Note() {
0
1977
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open ( +4) / 291 closed ( +4) / 553 total ( +8) New / Reopened Patches ______________________
0
1796
by: LiveTecs | last post by:
http://www.livetecs.com TimeLive Web Collaboration Suite is an integrated suite that allows you to manage project life cycle including tasks, issues, bugs, timesheet, expense, attendance. TimeLive is available in two different flavors. Hosted version and downloadable version. Downloadable version required certain system requirement to install on local server. Whereas hosted version is already installed on our fully managed server on...
12
2046
by: Juan T. Llibre | last post by:
re: !I found an MSDN document that explains why what I'm trying to do should work Lee, From : http://www.w3.org/TR/REC-xml/ "A special attribute named xml:lang may be inserted in documents to specify the
0
8462
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8586
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8658
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7401
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.