473,785 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VC++ 6.0 / 7.0 compilation difference ?

[SUMMARY]
Observed a compilation error reporting differences between VC++ 6.0 and
7.0 VS .NET 2003.
Seeking opinions.

[IN DETAILS]

Here is the code abbreviated:-

main()
{

// xxxxxxxxx other code xxxxxxxxxxxxxxx

if(<<something= =1>>)
{
goto Label_1;
//xxxxx other code xxx
}

<<pointer variable declaration + definition here>>;
Label_1:
//xxxxxxxxxxxxoth er code xxxxxxxxxxxxxxx x
}

When I compiled this in 6.0, it gave me error saying that goto is
skipping the pointer variable's definition. But 7.0 did not give such a
error.

Both places, settings were error level 3, which did NOT mean treating
warnings as errors.

Any ideas, how this difference?

Thanks.

- Kedar Agarkar

Jul 23 '05 #1
5 1923
id*******@math. net wrote:
[SUMMARY]
Observed a compilation error reporting differences between VC++ 6.0 and
7.0 VS .NET 2003.
Seeking opinions.

[IN DETAILS]

Here is the code abbreviated:-

main()
{

// xxxxxxxxx other code xxxxxxxxxxxxxxx

if(<<something= =1>>)
{
goto Label_1;
//xxxxx other code xxx
}

<<pointer variable declaration + definition here>>;
Label_1:
//xxxxxxxxxxxxoth er code xxxxxxxxxxxxxxx x
}

When I compiled this in 6.0, it gave me error saying that goto is
skipping the pointer variable's definition. But 7.0 did not give such a
error.

Then 7.0 is wrong. Call microsoft and complain. You are not
permitted to jump over initializaitons of variables. The general
way to fix it is to wrap a block around the stuff between the if
and Lable_1 so that they are not in scope at the point of the jump.
Jul 23 '05 #2
id*******@math. net wrote:
[SUMMARY]
Observed a compilation error reporting differences between VC++ 6.0 and
7.0 VS .NET 2003.
Seeking opinions.

[IN DETAILS]

Here is the code abbreviated:-

main()
{

// xxxxxxxxx other code xxxxxxxxxxxxxxx

if(<<something= =1>>)
{
goto Label_1;
//xxxxx other code xxx
}

<<pointer variable declaration + definition here>>;
Label_1:
//xxxxxxxxxxxxoth er code xxxxxxxxxxxxxxx x
}

When I compiled this in 6.0, it gave me error saying that goto is
skipping the pointer variable's definition. But 7.0 did not give such a
error.
What's "something" ? Could it be the condition inside 'if' was always
"false" and 7.0 recognized that?

Hint: ALWAYS post _real_ compilable code, no "abbreviate d" versions.
Both places, settings were error level 3, which did NOT mean treating
warnings as errors.

Any ideas, how this difference?


Also remember that compiler-specific questions should be addressed to
a compiler-specific newsgroups (microsoft.publ ic.vc.language) . I am *not*
saying that this question is necessarily compiler-specific. Besides, it
cannot be answered without seeing the _real_ code.

V
Jul 23 '05 #3

"Ron Natalie" <ro*@spamcop.ne t> wrote in message
news:42******** *************** @news.newshosti ng.com...
id*******@math. net wrote:
[SUMMARY]
Observed a compilation error reporting differences between VC++ 6.0 and
7.0 VS .NET 2003.
Seeking opinions.

[IN DETAILS]

Here is the code abbreviated:-

main()
{

// xxxxxxxxx other code xxxxxxxxxxxxxxx

if(<<something= =1>>)
{
goto Label_1;
//xxxxx other code xxx
}

<<pointer variable declaration + definition here>>;
Label_1:
//xxxxxxxxxxxxoth er code xxxxxxxxxxxxxxx x
}

When I compiled this in 6.0, it gave me error saying that goto is
skipping the pointer variable's definition. But 7.0 did not give such a
error.

Then 7.0 is wrong. Call microsoft and complain. You are not permitted
to jump over initializaitons of variables. The general
way to fix it is to wrap a block around the stuff between the if
and Lable_1 so that they are not in scope at the point of the jump.


It's not that it's broken, really. It's a VC++ 7 compiler option. When
compiled with /Za (to "disable language extensions"), the code below will
fail:

int a = 1;
if (a < 2)
goto Label1;
int* pa = &a;
Label1:
if (pa)
return;

But /Za is not the default for VC++ 7 (and if I recall, can break some of
their library code?). So it is accepted by the compiler.

It's just plain dumb that MS decided to allow this by default. The code
makes no sense, since it will try to test the value of a pointer which is
not defined. I haven't tried running it to see what happens. Undefined
behavior scares me! :-)

-Howard


Jul 23 '05 #4
Thanks Ron and Howard.
- Kedar

Howard wrote:
"Ron Natalie" <ro*@spamcop.ne t> wrote in message
news:42******** *************** @news.newshosti ng.com...
id*******@math. net wrote:
[SUMMARY]
Observed a compilation error reporting differences between VC++ 6.0 and
7.0 VS .NET 2003.
Seeking opinions.

[IN DETAILS]

Here is the code abbreviated:-

main()
{

// xxxxxxxxx other code xxxxxxxxxxxxxxx

if(<<something= =1>>)
{
goto Label_1;
//xxxxx other code xxx
}

<<pointer variable declaration + definition here>>;
Label_1:
//xxxxxxxxxxxxoth er code xxxxxxxxxxxxxxx x
}

When I compiled this in 6.0, it gave me error saying that goto is
skipping the pointer variable's definition. But 7.0 did not give such a
error.

Then 7.0 is wrong. Call microsoft and complain. You are not permitted
to jump over initializaitons of variables. The general
way to fix it is to wrap a block around the stuff between the if
and Lable_1 so that they are not in scope at the point of the jump.


It's not that it's broken, really. It's a VC++ 7 compiler option. When
compiled with /Za (to "disable language extensions"), the code below will
fail:

int a = 1;
if (a < 2)
goto Label1;
int* pa = &a;
Label1:
if (pa)
return;

But /Za is not the default for VC++ 7 (and if I recall, can break some of
their library code?). So it is accepted by the compiler.

It's just plain dumb that MS decided to allow this by default. The code
makes no sense, since it will try to test the value of a pointer which is
not defined. I haven't tried running it to see what happens. Undefined
behavior scares me! :-)

-Howard


Jul 23 '05 #5
Victor Bazarov wrote:
id*******@math. net wrote:
[SUMMARY]
Observed a compilation error reporting differences between VC++ 6.0 and
7.0 VS .NET 2003.
Seeking opinions.

[IN DETAILS]

Here is the code abbreviated:-

main()
{

// xxxxxxxxx other code xxxxxxxxxxxxxxx

if(<<something= =1>>)
{
goto Label_1;
//xxxxx other code xxx
}

<<pointer variable declaration + definition here>>;
Label_1:
//xxxxxxxxxxxxoth er code xxxxxxxxxxxxxxx x
}

When I compiled this in 6.0, it gave me error saying that goto is
skipping the pointer variable's definition. But 7.0 did not give such a
error.


What's "something" ? Could it be the condition inside 'if' was always
"false" and 7.0 recognized that?


Even then, it should be an error. The validity of code must not depend on
the optimization behavior of the compiler.

Jul 23 '05 #6

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

Similar topics

1
1566
by: Paljo | last post by:
Trying to compile VC++ 6 project in VC++ 7 and getting a compiling error, error C2955: '_com_ptr_t' : use of class template requires template argument list Any thoughts? Thanks
8
1482
by: Greg Stoch | last post by:
Hi, I'm newcomer to Microsoft product (VS.net 7.0, C++) and need to understand, why the binary code obtained using VC++ compiler is so huge as compared to the code by Borland C++ 5.02 (the same source). The source code is standard C++, without any extensions, just standard libraries are statically linked in (/ML for VC++, Single Threaded). The respective sizes are: 52kb for BC.5.02 and 120kb (!) for VC++ 120kb. Release versions, of...
0
1985
by: Ganapathy | last post by:
I have COM dll code written in VC 6.0. When i tried compiling this code in VC 7, The MIDL cmpiler gets called twice. i.e. it initially compiles fully & immediately a line - 64 bit processing' comes, followed by the 64 bit compilation of the IDl file. The comlpilation goes thro' the full stage and then the StdAfx.cpp is compiled. I have another similar VC 6 COM dll code that gets compiled without invoking the 64 bit processing of the...
26
1966
by: _R | last post by:
Given that VS2005 has made an effort to clean up the syntax of VC++ (in C++/CLI), is there any future plans to do away with function protos, ala C#/VB? What are they needed for these days?
3
2238
by: kuiyuli | last post by:
I'm using VC++ .Net to do a simlple program. I tried to use <vector> <list> in the program, and I simply put the folowing lines " #include <list> #include <vector> #include <string> using namespace std; ...... vector <Vector> vectorlist;
6
2033
by: bramdoornbos | last post by:
Hello, I am looking for a solution to interface with C++ classes implemented in a dll compiled by gcc. This dll will be however accessed by a visual c++ compiled host (not made by me). Both implementations will share headers that define virtual c++ class interfaces.
5
3682
by: =?Utf-8?B?TmlzaGFsIFBhdGVs?= | last post by:
I converted my VC++ 6.0 Project to VC++.NET and during compilation, I get the following error everywhere: Error 1 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int g:\argusweb\source\gssutil\xmlmessage.h 20 If is referring to the line: log_comment(char *psz_comment, long bStart=0); You can see it in the .h file below:
35
3056
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files. In C#, there appears to be no analog. I have to compile all my .cs files into a single .dll. This has serious drawbacks in terms of compilation. With Eclipse, I change a file and only that file is re-compiled. With Visual Studio, I
9
1851
by: =?Utf-8?B?S3VlaXNoaW9uZyBUdQ==?= | last post by:
What is the difference between the regular VC++ edition and the VC++ express edition? If there is not too much difference in functionality, why the express edition is free?
0
9643
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
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10087
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
9947
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
8971
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...
0
5380
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
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
3645
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.