Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hm, the proposal is rather sensible but... didn't C99 introduce static-dimensions in array-typed function parameters? I'm pretty sure

    void copybyref(size_t n, int a[static n], const int b[static n]) {
        for (int i = 0; i < n; i++) {
            a[i] = b[i];
        }
    }
is valid C and has exactly the same semantics as the example from the proposal — except that in this case, "no diagnostic is required" to ensure that there are indeed (at least) n elements in both a and b arrays.


Checking this in general has ABI considerations. It allows the compiler to do some things at compile-time but beyond that it doesn't really work.


> Checking this in general has ABI considerations

Does it? Inserting a sanity check at every call site of e.g. memcpy (that neither of dst/src are NULL) is already kinda required for correctness even if people skip it and boldly go.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: