MS和Borland的冲突行为 [英] Conflicting behavior of MS and Borland
问题描述
我尝试了Borland C ++编译器[5.5.1]上的以下代码和
Microsoft VC7.0似乎都给出了相互矛盾的结果
void foo(const int& x){std :: cout<< 在const foo \ n中; }
void foo(int& x){std :: cout<< 在非const foo \ n中; }
int main(无效)
{
foo(5);
int x = 23;
foo((const int)x);
返回0;
}
如果是Borland编译器,结果是
在const foo中
在const foo中
案例VC7.0
在const foo
在非const foo
我找不到多少在TC ++ PL
-
Imanpreet Singh Arora
Minti写道:我在Borland C ++编译器[5.5.1]上尝试了以下代码,而且Microsoft VC7.0似乎都给出了相互矛盾的结果
void foo(const int& ; x){std :: cout<< 在const foo \ n中; }
void foo(int& x){std :: cout<< 在非const foo \ n中; }
int main(void)
{
foo(5);
int x = 23;
foo((const int)x);
返回0;
如果是Borland编译器,结果是
在const foo
在const foo
gcc 3.4.0和VC7.1也说了这个。
在VC7.0的情况下
在const foo
在non-const foo
我怀疑这是VC7.0中的一个错误。
我在TC ++ PL中找不到多少
Gianni Mariani写道:Minti写道:
我试过了以下关于Borland C ++编译器[5.5.1]和
Microsoft VC7.0的代码似乎都给出了相互矛盾的结果
void foo(const int& x){std :: cout<< ; 在const foo \ n中; }
void foo(int& x){std :: cout<< 在非const foo \ n中; }
int main(void)
{
foo(5);
int x = 23;
foo((const int)x);
返回0;
如果是Borland编译器,结果是
在const foo中
在const foo中
gcc 3.4.0和VC7.1也说明了这一点。
不是我拥有的VC7.1。它仍然与VC7.0相同。你有什么版本的
编译器?我说
Microsoft(R)32位C / C ++优化编译器版本13.10.3077
代表80x86
版权所有( C)Microsoft Corporation 1984-2002。保留所有权利。
我是否需要以某种方式更新它?
在VC7.0的情况下
在const foo中
在非const foo中
我怀疑这是VC7.0中的一个错误。
Victor Bazarov写道:不是我有的VC7.1。它仍然与VC7.0相同。你有什么版本的编译器?我的说法
Microsoft(R)32位C / C ++优化编译器版本13.10.3077
适用于80x86
版权所有(C)Microsoft Corporation 1984-2002。保留所有权利。
我是否需要以某种方式更新它?
我的编译器说:
Microsoft(R)32位C / C ++优化编译器版本13.10.3052(适用于80x86)
I.e.它比你的年龄大一点。如果我关闭微软的分机
(/ Za),我得到预期的:
在const foo
在const foo
只是我的
I tried the following code on Borland C++ complier [ 5.5.1 ] and
Microsoft VC7.0 both seem to give conflicting results
void foo(const int& x) { std::cout << "In const foo\n"; }
void foo(int& x) {std::cout << "In non-const foo\n"; }
int main(void)
{
foo(5);
int x = 23;
foo( (const int ) x );
return 0;
}
In case of Borland compiler the result is
In const foo
In const foo
While in case of VC7.0
In const foo
In non-const foo
I could not find much in TC++PL
--
Imanpreet Singh Arora
Minti wrote:I tried the following code on Borland C++ complier [ 5.5.1 ] and
Microsoft VC7.0 both seem to give conflicting results
void foo(const int& x) { std::cout << "In const foo\n"; }
void foo(int& x) {std::cout << "In non-const foo\n"; }
int main(void)
{
foo(5);
int x = 23;
foo( (const int ) x );
return 0;
}
In case of Borland compiler the result is
In const foo
In const foo
gcc 3.4.0 and VC7.1 also says this.
While in case of VC7.0
In const foo
In non-const foo
I suspect it''s a bug in VC7.0.
I could not find much in TC++PL
Gianni Mariani wrote:Minti wrote:I tried the following code on Borland C++ complier [ 5.5.1 ] and
Microsoft VC7.0 both seem to give conflicting results
void foo(const int& x) { std::cout << "In const foo\n"; }
void foo(int& x) {std::cout << "In non-const foo\n"; }
int main(void)
{
foo(5);
int x = 23;
foo( (const int ) x );
return 0;
}
In case of Borland compiler the result is
In const foo
In const foo
gcc 3.4.0 and VC7.1 also says this.
Not the VC7.1 I have. It still says the same as VC7.0. What version of
the compiler do you have? Mine says
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077
for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
Do I need to update it somehow?
While in case of VC7.0
In const foo
In non-const foo
I suspect it''s a bug in VC7.0.
Victor Bazarov wrote:Not the VC7.1 I have. It still says the same as VC7.0. What version of
the compiler do you have? Mine says
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077
for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
Do I need to update it somehow?
My compiler says:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3052 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
I.e. it''s a bit older than yours. If I turn Microsoft''s extension off
(/Za), I get the expected:
In const foo
In const foo
Just my
这篇关于MS和Borland的冲突行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!