On Friday, September 20th, 2024 at 8:56 AM, Stuff Received <stuff(a)riddermarkfarm.ca>
wrote:
Moved to COFF.
On 2024-09-20 11:07, Dave Horsfall wrote (in part):
Giggle... In a device driver I wrote for V6, I
used the expression
"0123"[n]
and the two programmers whom I thought were better than me had to ask me
what it did...
-- Dave, brought up on PDP-11 Unix[*]
[*]
I still remember the days of BOS/PICK/etc, and I staked my career on Unix.
Working on embedded systems, we often used constructs such as a[-4] to
either read or modify stuff on the stack (for that particular
compiler+processor only).
S.
My takeaway on out of bounds array access is you're taking the wheel in your own
hands WRT the memory characteristics of your application. If you're using some
pointer to the middle of a known memory region (e.g. I/O registers) then you're fine
stepping a subscript out of bounds in either direction. If you're making assumptions
about how compiler and linker <xyz> are going to map C abstractions into
RAM/stack...then you better be prepared for a compiler author to have a different mapping
plan in mind. As John Mashey put it, paraphrasing, C doesn't require you to agonize
over all the details of the machine, but it also allows you to get at many of those
details if you so choose.
- Matt G.