Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#21 Undefined expressions

open
nobody
None
5
2011-04-11
2011-04-11
John Bollinger
No

g++ complains about certain expressions in the Pixie sources having undefined results. The affected expressions are all of the form:

*p++ = (*p) * foo;

G++ is right. It is formally undefined whether the value of p dereferenced on the right-hand side is the value before or after it is incremented by the increment operator on the left-hand side. The left-hand side is ok by itself. Different compilers or different optimization options likely produce different results for such expressions.

I infer that in each case (11, in four files), the intention is to increment the pointer last of all, but that should be verified. The attached patch against version 2.2.6 fixes the expressions correspondingly.

Discussion

  • John Bollinger
    John Bollinger
    2011-04-11

    Patch for several undefined expressions in 2.2.6

     
  • Eibriel
    Eibriel
    2011-04-11

    Thanks John!
    I'll add the patch to the code (eibriel branch) as soon I can.
    Hopefully it will solve some bug :)

    Thanks!!