David Holland wrote:
On Sun, Feb 10, 2008 at 09:31:31AM +1100, Darren Reed wrote: > Can anyone explain why gcc is doing what it is below?> > [...]> (gdb) print hlen > $1 = 4448 Does slen (set to l3len - hlen) come out correct? Given that it's inlined htons, I'm assuming you compiled with a nontrivial -O level, so it shouldn't be surprising either that it optimized out a local variable or that the debug info gives you misleading results which may or may not reflect what's actually happening.
No, slen is wrong and that's the problem: the program later core dumps beause it is wrong. The code was compiled with "-O", not -O2 or -O3. Darren