Menu

#21 Undefined expressions

open
nobody
None
5
2011-04-11
2011-04-11
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!!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.