473,769 Members | 3,232 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference to an un-initialized variable in release build in VC6/VC

Can anyone talk me is there existed a "default" value for a un-initialized
int variable in a release build in VC6 and VC7.1. (I know there is a
compilation warning)

For Example:
main(){
int a;
printf("variabl e 'a' is un-initialized and its value is = %d\n", a);
}
I want to know whether the compiler will assign a "default" value to
variable 'a' during the release building and the behaviour are the same
between VC6 and VC7.1?

Thanks and regards,
lauch2.
Nov 17 '05 #1
3 1523

"lauch2" <la****@discuss ions.microsoft. com> wrote in message
news:5A******** *************** ***********@mic rosoft.com...
Can anyone talk me is there existed a "default" value for a un-initialized
int variable in a release build in VC6 and VC7.1. (I know there is a
compilation warning)

For Example:
main(){
int a;
printf("variabl e 'a' is un-initialized and its value is = %d\n", a);
}
I want to know whether the compiler will assign a "default" value to
variable 'a' during the release building and the behaviour are the same
between VC6 and VC7.1?

Thanks and regards,
lauch2.


As far as I known, neither VC6 or VC7.1 do any initializtion on variables in
release mode. You get a random value. That being said, in my opinion, all
variables should be initialized. Always. I've seen lots of subtle (and not
so subtle) failures caused by unitilized variables. Always initialize ---
it'll save you grief in the long run.

Mike P
Nov 17 '05 #2
> As far as I known, neither VC6 or VC7.1 do any initializtion on variables in
release mode. You get a random value. That being said, in my opinion, all
variables should be initialized. Always. I've seen lots of subtle (and not
so subtle) failures caused by unitilized variables. Always initialize ---
it'll save you grief in the long run.

Mike P


Thanks Mike, I totally agree with you and I have experienced some unexpected
exception due to the un-initialized variable. I am posting the question just
becuase I right now need to migrate someone's code to VC7.1 and find some
variables had not been initialized before refering them. It seems the
behaviour for un-initialized variable has been changed in VC7.1.

Further comment on this issue are appreciated!

Thanks in advance,
lauch2

Nov 17 '05 #3
Hi lauch2!
As far as I known, neither VC6 or VC7.1 do any initializtion on variables in
release mode. You get a random value. That being said, in my opinion, all
variables should be initialized. Always. I've seen lots of subtle (and not
so subtle) failures caused by unitilized variables. Always initialize ---
it'll save you grief in the long run.


Thanks Mike, I totally agree with you and I have experienced some unexpected
exception due to the un-initialized variable. I am posting the question just
becuase I right now need to migrate someone's code to VC7.1 and find some
variables had not been initialized before refering them. It seems the
behaviour for un-initialized variable has been changed in VC7.1.


AFAIK the behaviour has not been changed... the only thing which was
changed, is that the compiler will generate a warning if a variable is
used without initialization.

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Nov 17 '05 #4

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

Similar topics

5
2874
by: Nico | last post by:
Hello folks, I am currently storing a set of objects inside an array, $itemlist = array(); $itemlist = new item("myitem"); //... and I am looking to develop a search function, which returns a reference to the found item.
3
3898
by: pascal Joseph | last post by:
J'ai un formulaire avec un seul champ text appelé "unite" et un bouton. En javascript j'aimerai utiliser un script qui interdise les valeurs de type "char" et soit supérieur à 0 J'ai trouvé ce code mais je ne sais pas comment l'appliquer, fonctionne-t-il? <script>
0
459
by: Zippy | last post by:
Some months ago, we requested help from this newsgroup on how to replace the library reference of a database with another library reference, prior to creating an MDE. I got the following answer from Stephen K. Young, which does the job: >In message <ahjurk$t18vo$1@ID-65843.news.dfncis.de>, Stephen K. Young ><s@k.y.invalid> writes >Using automation you can temporarily replace a developer library reference >with a compiled library...
3
16102
by: Jorge Gallardo | last post by:
Hola de nuevo a todos... Agradecido a todos los que me habeis solucionado problemas anteriores... Pero como no es novedad, me surge otro. Recientemente buscando, adquiri un codigo para juntar 3 ficheros de texto. El cual adapte para el desarrollo de mi DB. El proceso es genial, pues junto los tres ficheros pulsando solo un boton. (O determinada accion EVENTOS)
0
1566
by: JS | last post by:
Hello I want translate a project from VB6 to VB.Net 1.0 In this project I have a graph with a MsChart COM control. When I want make reference (Projet/Ref /Com controle) to this chart I have an error message " Tlbimp.exe not found. Reinstall VB.net". So Tlbimp is in my folder "D:\Program Files\Microsoft Visual Studio ..NET\FrameworkSDK\Bin" 1-How VB.net cant found the path for Tlbimp ? 2 Else maybe I must execute manually the wrapper...
8
4096
by: Michael Safyan | last post by:
Dear members of comp.lang.c++, I am a little bit confused about the differences between constant references and values. I understand that it is faster to use a constant reference ("const T&") than a value ("T") since the former does not require copying whereas the latter does, is that correct? Also, I un derstand that "const T&" allows for polymorphism whereas "T" will generate code cuttting. On the former points, I am fairly confident......
3
2901
by: nano9 | last post by:
Hola gente quisiera que alguien me pudiera ayudar con un problemilla que tengo, resulta que estoy programando en ASP con C# y estoy usando un cadbgrid que se comporta parecido a un datagrid o dbgrid pero tiene otras peculiaridades ahi que facilitan muchas tareas. Si alguno ha usado este control talvez me podria ayudar. El asunto esta asi, estoy queriendo agregar un mensaje en una etiqueta debajo del grid para indicar la cantidad de items...
1
1367
by: betti76 | last post by:
Ciao a tutti, ho un problema nella compilazione di un progetto vb net con reference ad activex. Se compilo gli activex e il progetto dal mio pc funziona tutto. Se richiamo il progetto da un altro pc e ricompilo ho problemi con le reference agli activex e comunque anche sistemando le reference il progetto non li richiama ma dà errore... Il fatto è che tutto sta in sursafe e più persone lavorano sul progetto su pc differenti.. Non c'è...
4
2583
by: Mahmoud Al-Qudsi | last post by:
Hi all, I'm working on a C# project, and at some point I'm needing to pass the same stack to multiple functions. I found out the hard way that when I poss a stack by value it doesn't actually use a copy constructor to move the contents over to a new stack - the original stack is still modified by changes to the stack that was passed by value.
41
3674
by: Summercool | last post by:
Can we confirm the following? also someone said, Java also has "reference" like in C++, which is an "implicit pointer": Pointer and Reference --------------------- I am starting to see what pointer and reference are and how they relate to each other.
0
10223
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10000
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
9866
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
8879
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
7413
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
5310
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...
1
3968
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
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.