473,383 Members | 1,798 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,383 software developers and data experts.

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 1408
mi*********@gmail.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*********@gmail.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++.moderated.

/Peter

Nov 28 '06 #3
peter koch wrote:
mi*********@gmail.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++.moderated.
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*********@gmail.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++.moderated.

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
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...
5
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...
102
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...
16
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...
26
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);...
158
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...
8
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...
0
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...
0
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. ...
12
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.