Click on image to see enlargment
Santa and his elves are automating their Christmas delivery system. But one of the elves has made a critical error causing, in some areas, the actions to appear in an unexpected order. Can you find the problem? (Thanks to Frank Fosse for submtting the basic idea).
bug564.cpp lint Output
--- Module: bug564.cpp (C++) _ santa_do( i++, i++, i++ ); bug564.cpp(17) : Warning 564: variable 'i' depends on order of evaluation bug564.cpp(17) : Warning 564: variable 'i' depends on order of evaluation
Reference Manual Explanation
564 variable 'Symbol' depends on order of evaluation -- The named variable was both modified and accessed in the same expression in such a way that the result depends on whether the order of evaluation is left-to-right or right-to-left. One such example is: n + n++ since there is no guarantee that the first access to n occurs before the increment of n. Other, more typical cases, are given in the manual. Volatile variables are also checked for repeated use in an expression.
Previous Bug - Bug #443 - November 2011