access off end of array
access off end of array
Posted Mar 24, 2013 6:53 UTC (Sun) by alankila (guest, #47141)In reply to: access off end of array by pflugstad
Parent article: Regehr: GCC 4.8 Breaks Broken SPEC 2006 Benchmarks
Posted Mar 25, 2013 19:27 UTC (Mon)
by tjc (guest, #137)
[Link] (7 responses)
i++;
as a stand-alone statement would be a useful compromise, since it could still be used as the increment statement in a for loop, which is by far the most common idiom for this construct.
Posted Mar 25, 2013 23:13 UTC (Mon)
by HelloWorld (guest, #56129)
[Link] (4 responses)
Posted Mar 26, 2013 0:34 UTC (Tue)
by tjc (guest, #137)
[Link] (3 responses)
The Development of the C Language I think i++ is fine from a syntax point of view, so long as it's a stand-along statement, where it produces the same code as i += 1. But I try to avoid embedding increment operators within expressions that produce easily overlooked side effects.
Posted Mar 26, 2013 9:00 UTC (Tue)
by khim (subscriber, #9252)
[Link] (2 responses)
Well, your own link shows that it's not an "urban legend" but more like oversimplification: This is historically impossible, since there was no PDP-11 when B was developed. The PDP-7, however, did have a few `auto-increment' memory cells, with the property that an indirect memory reference through them incremented the cell. This feature probably suggested such operators to Thompson; the generalization to make them both prefix and postfix was his own. While factually incorrect (C design predates PDP-11) both "++" in C and
"(RX)+" in PDP-11's assembler come from the same source.
Posted Mar 26, 2013 16:04 UTC (Tue)
by hummassa (guest, #307)
[Link] (1 responses)
a = *b++
was a single instruction; they made easy to implement real fast stacks and queues, and zero-terminated strings (because "a = *b++" &c set the Z flag if the char was zero).
Posted Mar 26, 2013 16:52 UTC (Tue)
by brouhaha (guest, #1698)
[Link]
Posted Mar 26, 2013 8:09 UTC (Tue)
by alankila (guest, #47141)
[Link] (1 responses)
Posted Mar 26, 2013 16:26 UTC (Tue)
by tjc (guest, #137)
[Link]
access off end of array
access off end of array
Actually, the ++/PDP-11 connection is urban legend -- see "More History", paragraph 2 at this link:
access off end of array
access off end of array
Actually, the ++/PDP-11 connection is urban legend -- see "More History", paragraph 2 at this link:
The Development of the C Languageaccess off end of array
a = *++b
a = *b--
a = *--b
*b++ = a
*++b = a
*b-- = a
*--b = a
Yes, but the 6809 came along much later than the PDP-11, so it's not relevant to discussion of where the C pre/post-increment/decrement operators came from.
access off end of array
access off end of array
access off end of array