3 ms·
It's not a bug. You're seeing the difference between "this is how you're taught to access arrays" and "this is how array access actually works".
by WolfeReader 2y ago
It's not a bug. You're seeing the difference between "this is how you're taught to access arrays" and "this is how array access actually works".
- WalterBright 2y agoSince the Standard specifies what that does, pedantically it is not a bug. Ok. But I call it a bug because it has no use and just pointlessly confuses people.
- im3w1l 2y agoWell it could (and I agree with WalterBright that it should) have been disallowed. a[b] being implemented as an early stage rewrite rule expanding to *(a+b) is an uninteresting implementation detail. And I doubt it is even implemented that way in modern compilers anyway. It certainly can't be in C++ as a[b] and b[a] mean different things when [] is overloaded.
- WolfeReader 2y agoThat "uninteresting implementation detail" is actually of grave importance when it comes to understanding how buffer overflow attacks work. I hate to think anyone would put C code into production without understanding this.
- kragen 2y agoYou seem to be lecturing the author of one of the most prominent early C compilers on how array access actually works in C.
- WolfeReader 2y agoYep.