Re: List of optimizations enabled by -O1 seems incorrect

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kevin P. Fleming wrote:
> Ian Lance Taylor wrote:
> 
>> Andrew's point was not that the program was non-conforming.  His point
>> was that a conforming program could not detect this optimization.  And,
>> indeed, it couldn't.  The issue was reported by valgrind, not by the
>> program itself.
> 
> OK, I get it now. This is the same sort of thing we see when strlen()
> reads past the end of the string, but doesn't actually use the extra
> bytes it read as part of its operation... valgrind complains, but the
> program works as expected.
> 
> However, in this case, valgrind didn't say it was a read of an
> uninitialized variable, it said the conditional jump depended on the
> value of an uninitialized variable; either that's a valgrind bug, or the
> jump may take different paths based on that content, or I'm not really
> awake enough this morning yet :-)

gcc looks at

  if (!foo && !bar)
    ...

and turns it into

  if (foo|bar)
    goto x;
  ...
 x:

So, from Valgrind's point of view, the branch depends on the value of
bar, which is uninitialized.  We know that if foo is nonzero there is
no such dependency, but Valgrind would have to do some heavyweight
dependency analysis to figure that one out.

Andrew.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux