POV-Ray : Newsgroups : povray.off-topic : Adventures with C++ : Re: Adventures with C++ Server Time
29 Jul 2024 02:27:45 EDT (-0400)
  Re: Adventures with C++  
From: Warp
Date: 24 May 2013 12:58:15
Message: <519f9c27@news.povray.org>
Orchid Win7 v1 <voi### [at] devnull> wrote:
> Apparently Google is your friend. After some minimal amount of effort, I 
> came across a very well-written forum post which helpfully explains that 
> in Debug mode all variables are guaranteed to be initialised to default 
> values, whereas in Release mode variables take on whatever random 
> gibberish happens to be in memory, unless you remember to explicitly 
> initialise them to something sane.

Initializing variables takes clock cycles, which is why C hackers don't
want them being initialized in situations where they are going to be
assigned to anyway... (As if this matters at all in 99.999% of the cases.)

Many compilers will analyze the code and give a warning about variables
being used uninitialized, but this analysis will always be inevitably
limited (because, as you may know, proving that eg. a variable is used
uninitialized is an improvable problem.)

There are some external tools that can be used to analyze the program
while it runs, and will detect things like this (as well as memory leaks
and accessing freed memory or out-of-bound accesses.) The only free one
I know of is valgrind. However, it only works on Linux and Mac OS X. No
such luck in Windows.

There are commercial programs that do the same (and more.) One that I know
of is AQtime.

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.