Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Loops (was Re: do { quit; } else { }) Date: Tue, 10 Jun 2025 06:01:20 -0700 Organization: A noiseless patient Spider Lines: 34 Message-ID: <86jz5jrbrz.fsf@linuxsc.com> References: <20250415153419.00004cf7@yahoo.com> <86h62078i8.fsf@linuxsc.com> <20250504180833.00000906@yahoo.com> <86plggzilx.fsf@linuxsc.com> <86ldr4yx0x.fsf@linuxsc.com> <1000cs3$2234m$1@dont-email.me> <87sel8nqid.fsf@nosuchdomain.example.com> <20250513202557.281@kylheku.com> <87o6vvbxmp.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Tue, 10 Jun 2025 15:01:20 +0200 (CEST) Injection-Info: dont-email.me; posting-host="1fbd55e74bfc4309a280a41a1d3a3e6e"; logging-data="1318879"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/x2hdsbwwzeyTbOPFRGtBB9Uz0+Z9fcQo=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:pi/GWXVG6st8CAb0IEQfhLmkS0s= sha1:bpUctjixoZD0Y7g1HPCaccjhe3w= Xref: csiph.com comp.lang.c:393787 Keith Thompson writes: > Kaz Kylheku <643-408-1753@kylheku.com> writes: > [...] > >> Progarms that manipulate strings using standard library functions >> often take advantage of the above. Strings are defined as >> null-terminated arrays; but it is very common for strings to be >> arrays that are displaced within larger arrays. > > To be pedantic, a string is defined as "a contiguous sequence of > characters terminated by and including the first null character". > The word "array" is not used. It does seem fairly obvious that > the contiguous sequence will be stored in an array (array > object?), but the standard doesn't quite say so. Consider the following program: #include #include typedef unsigned long long ULL; ULL hello = ((((0ULL +'o' <<8) +'l' <<8) +'l' <<8) +'e' <<8) + 'h'; int main(){ printf( "length is %zu\n", strlen( (char*)&hello ) ); return 0; } On a little endian machine (with CHAR_BIT == 8) this program works, and TTBOMK conforms to both the letter and the spirit of the C standard, without any undefined behavior (on that platform). Yet there are no arrays in sight, and certainly no array objects.