|
From: Andy \Axel\ B. <val...@th...> - 2008-01-13 08:39:22
|
On Sun, 2008-01-13 at 10:24 +1100, Nicholas Nethercote wrote: > On Fri, 11 Jan 2008, Andy "Axel" Bakun wrote: > > >> I will check out the difference in ASM between the two situations to > >> see if that can yield some more light on the situation. Constant vs > >> variable initialisation would surely be a major "gotcha" in the C++ > >> specs if this is indeed the case. > > > > According to objdump -d, gcc 4.1.2 20070925 produces the exact same > > series of instructions for the following three constructs: > > > > bool done = (test > 3); > > bool done(test > 3); > > bool done; done = (test > 3); > > > > So that was a useless suggestion, at least for this compiler. Sorry for > > the wild goose chase. > > If Valgrind is doing different things in the two cases then there must be > some difference at the binary level. Could there be some static > constructors involved that run at start-up, or something like that? For the record, I didn't see any differences, but obviously Jonathan Marshall has. I did run all three versions compiled at all five optimization levels against both execution paths through memcheck and received no errors. gcc produces the exact same executable for all versions at the same optimization level (using sha1sum), so consistency is expected. Attached is the test script I used if someone wants to give it a try with some other combination of compiler, valgrind or platform. Do you have something different than these, Jonathan? $ g++ --version g++ (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33) $ valgrind --version valgrind-3.2.3 $ uname -a Linux hex 2.6.23.9-85.fc8 #1 SMP Fri Dec 7 15:49:59 EST 2007 i686 athlon i386 GNU/Linux |