Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Loops (was Re: do { quit; } else { }) Date: Mon, 12 May 2025 13:38:46 -0700 Organization: None to speak of Lines: 23 Message-ID: <8734d936p5.fsf@nosuchdomain.example.com> References: <20250413072027.219@kylheku.com> <20250415153419.00004cf7@yahoo.com> <86h62078i8.fsf@linuxsc.com> <20250504180833.00000906@yahoo.com> <86plggzilx.fsf@linuxsc.com> <86ldr4yx0x.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 12 May 2025 22:38:47 +0200 (CEST) Injection-Info: dont-email.me; posting-host="ec3410180c1ee7cec196ae011e16bd7a"; logging-data="1352697"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/gbVS3RurvNnKsHDls334m" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:GD99M6pa788nnxN4qI4ByV8udWY= sha1:pw+3qWQXfzzjiCVP6ApgZBJFSa8= David Brown writes: [...] > I am not convinced that it is actually useful as an error checking > mechanism in many situations. In a lot of code, you simply don't have > a compile-time checkable array sizes - you have a pointer, and a > run-time variable for the size. When you are calling your function > with a "static" array size, the compiler does not have any way to > check your pointer for correctness. [...] Using [static N] in an array parameter declaration also requires the caller to pass a non-NULL pointer. If I want to tell the compiler that an argument must not be a NULL pointer, I can write: void func(int arg[static 1]); func(NULL) then has undefined behavior, and a compiler is likely to warn about it. (Of course some UB will be missed if the compiler can't detect it.) -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */