Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #389160
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: 80386 C compiler |
| Date | 2024-11-27 19:26 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <86v7w8ox7m.fsf@linuxsc.com> (permalink) |
| References | (1 earlier) <vhvsm9$2bmq9$1@dont-email.me> <vi0dt1$2el7m$1@dont-email.me> <20241125101701.894@kylheku.com> <qrp9kjd09n2v3srmabqccmnsbr1r6nkm2m@4ax.com> <20241125132021.212@kylheku.com> |
Kaz Kylheku <643-408-1753@kylheku.com> writes:
> On 2024-11-25, Rosario19 <Ros@invalid.invalid> 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.
Challenge exercise for C standard enthusiasts: It is possible
(in C99 and later) to write an initializer for x[] that puts
in the same values as the initializer above, but guarantees
foo() is called before bar(). Hint: nothing else is needed
besides a different writing of the initializer for x[] (still
an array of length 3). How to do it?
Back to comp.lang.c | Previous | Next | Find similar
Re: 80386 C compiler Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-11-27 19:26 -0800
csiph-web