Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: Memory protection between compilation units? Date: Mon, 16 Jun 2025 01:01:35 -0000 (UTC) Organization: A noiseless patient Spider Lines: 37 Message-ID: <20250615175532.971@kylheku.com> References: <20250611153239.6bc43323@mateusz> <20250612102857.1632c026@mateusz> <20250612114200.143@kylheku.com> <102gjib$39la2$1@dont-email.me> <20250613141420.25d81b43@mateusz> <20250613165623.00004eb3@yahoo.com> <102kq3e$e9ts$1@dont-email.me> <102mjh5$31ckr$1@paganini.bofh.team> <102nab5$148mb$1@dont-email.me> <102nm7l$3333o$1@paganini.bofh.team> Injection-Date: Mon, 16 Jun 2025 03:01:36 +0200 (CEST) Injection-Info: dont-email.me; posting-host="7c1903d0d66bea197761554c29c759e9"; logging-data="1298870"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+1Ys6cZ1ltEynP3hR1C0s5N6kGF5sSK4=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:2zB48Wip0mDLgqS+WJkPBKbJcOg= On 2025-06-15, Waldek Hebisch wrote: > Mateusz Viste 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".