Deutsch   English   Français   Italiano  
<8734d936p5.fsf@nosuchdomain.example.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Keith Thompson <Keith.S.Thompson+u@gmail.com>
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: <vspbjh$8dvd$1@dont-email.me> <vtf7fe$1qtpg$1@dont-email.me>
	<vtgfuf$31ug1$1@dont-email.me> <20250413072027.219@kylheku.com>
	<vtgpce$39229$1@dont-email.me> <vti2ki$g23v$1@dont-email.me>
	<vtin99$vu24$1@dont-email.me> <vtiuf0$18au8$1@dont-email.me>
	<vtj97r$1i3v3$1@dont-email.me> <vtl166$36p6b$1@dont-email.me>
	<vtlcg0$3f46a$2@dont-email.me> <20250415153419.00004cf7@yahoo.com>
	<86h62078i8.fsf@linuxsc.com> <20250504180833.00000906@yahoo.com>
	<86plggzilx.fsf@linuxsc.com> <vvnsvt$3k1mu$1@dont-email.me>
	<86ldr4yx0x.fsf@linuxsc.com> <vvpmm2$3dhl$1@dont-email.me>
	<vvpsji$4jht$1@dont-email.me> <vvr5mg$l85c$1@dont-email.me>
	<vvt2tg$14otk$2@dont-email.me>
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 <david.brown@hesbynett.no> 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 */