Deutsch   English   Français   Italiano  
<vvqfpp$gr89$1@dont-email.me>

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

Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Muttley@dastardlyhq.com
Newsgroups: comp.lang.c
Subject: Re: Loops (was Re: do { quit; } else { })
Date: Sun, 11 May 2025 15:30:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <vvqfpp$gr89$1@dont-email.me>
References: <vspbjh$8dvd$1@dont-email.me> <vtc19j$2kqlj$1@dont-email.me>
 <87a58mqt2o.fsf@nosuchdomain.example.com> <vtc7mp$2q5hr$1@dont-email.me>
 <vtcqf6$3j95s$1@dont-email.me> <vtdh4q$b3kt$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>
Content-Type: text/plain; charset=UTF-8; format=flowed
Injection-Date: Sun, 11 May 2025 17:30:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="8eb5e38b0d3f70ad1581c5ed912dfabc";
	logging-data="552201"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18PuN3uR2PbCbEzHHqIseQc"
Cancel-Lock: sha1:Q24xfkik5j2ayatd0e60r9Ym0Ys=

On Sun, 11 May 2025 12:02:25 +0200
David Brown <david.brown@hesbynett.no> gabbled:
>double average(double values[static 4]) {
>	double total = 0.0;
>	for (int i = 0; i < 3; i++) {
>		total += values[i];
>	}
>	return  total / 3;
>}
>
>Without the "static 4", the compiler can only assume that it can access 
>up to 3 doubles from the "value" array.  But with "static 4", it knows 
>it is safe to read "values[3]" even though the code never needs to do 

Not sure I follow. C doesn't care if its safe or not, it'll just try and
read them anyway and if it can't and there's a memory leak or crash, well, 
tough luck mate. So I don't see why it would make a difference to the resulting
assembler.