Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: do { quit; } else { } Date: Sun, 13 Apr 2025 18:22:42 -0700 Organization: None to speak of Lines: 46 Message-ID: <87lds34jvh.fsf@nosuchdomain.example.com> References: <87a58mqt2o.fsf@nosuchdomain.example.com> <875xjaqmgf.fsf@nosuchdomain.example.com> <20250412101325.877@kylheku.com> <20250413214046.0000530f@yahoo.com> <20250413130116.546@kylheku.com> <87lds3g1vw.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 14 Apr 2025 03:22:43 +0200 (CEST) Injection-Info: dont-email.me; posting-host="81eb20b1af8ee11d07b9431bae23cc05"; logging-data="122838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/w6FgtB3jMrsKHZtEke4A9" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:+DUiSsoCugBU28qQa3en80v7GZI= sha1:sAlI2DyljRbX70EJ07cML+TqVv8= Xref: csiph.com comp.lang.c:392484 Thiago Adams writes: > Em 4/13/2025 6:58 PM, Keith Thompson escreveu: >> Kaz Kylheku <643-408-1753@kylheku.com> writes: >>> On 2025-04-13, Michael S wrote: >>>> The funny thing is that in original C prefix form of [] indexing was >>>> equivalent to the postfix form. May be, it still is in C23, I didn't >>>> try to look in the docs or test. >>> >>> Are you thinking of a[i] being *(a + i) being i[a] due to commutativity? >>> >>> That's really not a useful feature. Actually right down to a + i being >>> commutative when a is a pointer. It would be fine if only the >>> + combination were allowed. >> Agreed. The feature goes back to B, which was largely untyped, and >> there wasn't a strong distinction between integers and pointers. An >> expression like 5[6] would refer to a memory location, and depending >> on the system it might even work. >> The transition from B to C was an opportunity to restrict the >> ordering >> of the operands, but it wasn't taken. > > Proposal for c2y > https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3517.htm > > " A postfix expression followed by an expression in square brackets [ > ] is a subscripted designation of an element of an array. The use of > this operator with the first operand of integer type **is an > obsolescent feature.**" > > and make M[-1] a constrain In the proposal, a negative index is a constraint violation only if it's an integer constant expression, and only if the prefix is the name of an array object. ptr[-1] is still valid, for example: int arr[10]; int *ptr = arr+1; ptr[-1]; You probably meant to say this; your post appears to have been cut off. But yes, I'm glad to see swapping the operands being made obsolescent. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */