POV-Ray : Newsgroups : povray.off-topic : Adventures with C++ : Re: Adventures with C++ Server Time
29 Jul 2024 02:34:51 EDT (-0400)
  Re: Adventures with C++  
From: Orchid Win7 v1
Date: 23 May 2013 13:33:12
Message: <519e52d8$1@news.povray.org>
Today, I spent about 2 hours trying to figure out why the hell all the 
tests pass when I compile in Debug mode, but two of them fail if I 
compile in Release mode.

Literally, every time I run in Debug mode, all the tests pass. It only 
fails in Release mode. In particular, that means I can't fire up the 
debugger to see why it's failing. You can only debug in Debug mode, and 
in Debug mode it works perfectly.

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.

Ouch. >_<

Now I guess I understand why Java, C#, et al make such a fuss about 
insisting on explicit initialisation and / or explicitly specifying 
default initialisation rules...



The other fun thing is that C++ allows you to "throw" absolutely 
anything. Several places in the code throw std::string, presumably in 
the hope that this will result in some helpful error message being printed.

It doesn't. ;-)


Post a reply to this message

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