News for hackers. Stuff that matters.
Re:Linus on compiler warnings and code reviews by merlincorey on Wednesday September 23, 2015 @04:43PM (#10268038)
The warning is true - it is "at least" 10:

    char ten(char foo[static 10]);

    char ten(char foo[static 10]) { return foo[1]; }

    void generates_no_warning(void);

    void generates_no_warning() {
        char foo[30];
        ten(foo);
    }

    int main() {
        generates_no_warning();
    }
Modified also so it would build cleanly with -Weverything -Werror
Re:Linus on compiler warnings and code reviews by uxcn on Wednesday September 23, 2015 @05:15PM (#10268287)
It avoids stepping on memory elsewhere in the program though. My personal preference for C99 and above is to pass the length as a parameter.

    int do_stuff(size_t len, int64_t arr[len]);
It still suffers from the pointer decay problem, but it at least forces whoever is reading/writing the code to acknowledge the length.