Hacker News new | ask | show | jobs
by Sirened 1399 days ago
not really? It just changes how the compiler emits the x := *(addr + idx) operation where instead of doing something like

    ldr x, [addr, idx]
it just does

    sub t1, idx, #1
    ldr x, [addr, t1]
If we're talking about C, accessing invalid/OOB indices is undefined and so if idx happens to be zero and unsigned, we'll overflow and hit something unexpected, which is fine.
1 comments

That's what I was thinking too, except that they have a point. You might end up using more bytes to store indexes as variables (if the index is 256 for example), than you would with zero indexing.