Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: 80386 C compiler Date: Tue, 26 Nov 2024 13:05:12 -0800 Organization: None to speak of Lines: 53 Message-ID: <875xo9ln93.fsf@nosuchdomain.example.com> References: <20241125101701.894@kylheku.com> <20241125132021.212@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Tue, 26 Nov 2024 22:05:16 +0100 (CET) Injection-Info: dont-email.me; posting-host="b8ed4fba96f7c888069140f3cefc44ea"; logging-data="3798769"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/CYNVLzZKRNpw5ggf36dff" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:FC/BZsNKG8aYsLLJ09MZwcDSbWs= sha1:dBo+Dog9E5LOPWFFXYrKzd+r5ro= Bytes: 3118 Kaz Kylheku <643-408-1753@kylheku.com> writes: > On 2024-11-25, Rosario19 wrote: >> On Mon, 25 Nov 2024 18:23:58 -0000 (UTC), Kaz Kylheku wrote: >> >>>void fn(int a) >>> { >>> int x[3] = { foo(), bar(), a }; /* not in C90 */ >> >> is in the above foo() called before bar()? > > No, you cannot rely on that. Maybe it's fixed in a more recent standard, > but C99 (which I happen to have open in a PDF reader tab) stated that > "The order in which any side effects occur among the initialization list > expressions is unspecified.". This implies that there is no sequence > point between any two initializing expressions, which means we don't > know whose expression's function call takes place first. N3096 (C23 draft) has : """ The evaluations of the initialization list expressions are indeterminately sequenced with respect to one another and thus the order in which any side effects occur is unspecified. """ C23 is more explicit (redundant?) than C99, which doesn't mention the lack of a sequence point. (C11 dropped sequence points, replacing them with "sequenced before", "sequenced after", and "unsequenced", basically a new way of describing the same semantics.) Given: int n = 42; int a[] = { n++, n++ }; C99 could imply that the value of a is merely unspecified, either { 42, 43 } or { 43, 42 }. Though it can almost certainly be inferred from other parts of the C99 standard that there is no sequence point between the two evaluations of n++ (I haven't taken the time to check). > In any case, a C90 compiler with the above support as an extension to > C90 can specify rigid sequencing behavior. True, but I don't know of anyone who's interested in a C 90 compiler with this kind of extension. Paul Edwards has made it clear he's only interested in unextended C90, and anyone else can just use a more modern compiler. [...] -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */