Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Because the storage duration of the compound literal is associated with the for loop that contains it, dereferencing ints in the second loop results in undefined behavior 9 (Annex J of the C standard Standard  [ISO/IEC 9899:2011]).

Even if the region of memory that contained the compound literal is not written to between loops, the print loop will display the value MAX_INTS-1 for MAX_INTS lines. This is contrary to the intuitive expected result, which is that the integers 0 through MAX_INTS-1 would be printed in order.

...

[ISO/IEC 9899:2011]Section 6.5.2.5, "Compound Literals"