Sujet : Re: Memory protection between compilation units?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 16. Jun 2025, 02:01:35
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250615175532.971@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-06-15, Waldek Hebisch <
antispam@fricas.org> wrote:
Mateusz Viste <mateusz@not.gonna.tell> wrote:
That said, detecting out-of-bounds array access is no panacea. Memory
corruption can arise from various sources, such as dangling pointers or
poorly managed pointer arithmetic.
>
AFAICS there is no reason for explicit pointer arithmetic in well
written C programs.
LOL, you heard it here.
Implicit pointer arithmetic (coming from array
indexing) is done by compiler so should be no problem. Like in
Array indexing *is* pointer arithmetic.
Are you not aware of this equivalence?
(E1)[(E2)] <---> *((E1) + (E2))
In fact, let's draw the commutative diagram
(E1)[(E2)] <---> *((E1) + (E2))
^ ^
| |
| |
v v
(E2)[(E1)] <---> *((E2) + (E1))
You're not saying anything here other than that you like the p[i]
/notation/ better than *(p + i), and &p[i] better than p + i.
Great, thanks for sharing!
You're not doing yourself any favor by confusing
"not styled in my taste" with "not well written".