Re: 80386 C compiler

Liste des GroupesRevenir à cl c  
Sujet : Re: 80386 C compiler
De : Ros (at) *nospam* invalid.invalid (Rosario19)
Groupes : comp.lang.c
Date : 30. Nov 2024, 16:41:03
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <84cmkj1s1omp924i19bb6gms025sqbll6h@4ax.com>
References : 1 2 3 4 5 6
User-Agent : Forte Free Agent 1.93/32.576 English (American)
On Tue, 26 Nov 2024 17:59:08 -0000 (UTC), Kaz Kylheku  wrote:

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.
>
In any case, a C90 compiler with the above support as an extension to
C90 can specify rigid sequencing behavior.
>
void fn(int a)
 {
   int x[3];
   x[0]=foo(); x[1]=bar(); x[2]=a;
>
this would be ok with every C compiler
>
One problem is, if you're doing this because your compiler is C90, you
also have to do something about all declarations which follow the int
x[3], since they cannot occur after a statement.  You can add another
level of block nesting for them, or whatever.

 int fn(int a)
{ int x[3];
  int b=9;
   x[0]=foo(); x[1]=bar(); x[2]=a;
   return x[0]==0||a==b;
}

i don't see onother level of block nesting

Initialization is preferable to leaving an object uninitialized and
assigning. There is a scope where the name is visible, but the object
is not initialized, inviting code to be inserted there which tries
to use it.
>
If I needed foo to be called before bar, I would still rather do
the following than assignment:
>
 int f = foo();
 int b = bar();
 int x[3] = { f, b, a };

ok

Date Sujet#  Auteur
24 Nov 24 * 80386 C compiler36Paul Edwards
24 Nov 24 +* Re: 80386 C compiler6fir
24 Nov 24 i+* Re: 80386 C compiler2fir
25 Nov 24 ii`- Re: 80386 C compiler1Paul Edwards
24 Nov 24 i`* Re: 80386 C compiler3Bart
25 Nov 24 i `* Re: 80386 C compiler2BGB
25 Nov 24 i  `- Re: 80386 C compiler1Paul Edwards
24 Nov 24 +* Re: 80386 C compiler24Janis Papanagnou
25 Nov 24 i`* Re: 80386 C compiler23Paul Edwards
25 Nov 24 i `* Re: 80386 C compiler22Kaz Kylheku
25 Nov 24 i  +* Re: 80386 C compiler20Rosario19
26 Nov 24 i  i`* Re: 80386 C compiler19Kaz Kylheku
26 Nov 24 i  i +* Re: 80386 C compiler7Keith Thompson
26 Nov 24 i  i i+* Re: 80386 C compiler5Paul Edwards
27 Nov 24 i  i ii`* Re: 80386 C compiler4Keith Thompson
27 Nov 24 i  i ii `* Re: 80386 C compiler3Paul Edwards
27 Nov 24 i  i ii  `* Re: 80386 C compiler2Keith Thompson
27 Nov 24 i  i ii   `- Re: 80386 C compiler1Paul Edwards
28 Nov 24 i  i i`- Re: 80386 C compiler1Tim Rentsch
27 Nov 24 i  i +* Re: 80386 C compiler9David Brown
27 Nov 24 i  i i`* Re: 80386 C compiler8Kaz Kylheku
27 Nov 24 i  i i +* Re: 80386 C compiler6James Kuyper
27 Nov 24 i  i i i`* Re: 80386 C compiler5Kaz Kylheku
28 Nov 24 i  i i i `* Re: 80386 C compiler4James Kuyper
30 Nov 24 i  i i i  `* Re: 80386 C compiler3Kaz Kylheku
30 Nov 24 i  i i i   +- Re: 80386 C compiler1Tim Rentsch
30 Nov 24 i  i i i   `- Re: 80386 C compiler1James Kuyper
28 Nov 24 i  i i `- Re: 80386 C compiler1David Brown
28 Nov 24 i  i +- Re: 80386 C compiler1Tim Rentsch
30 Nov 24 i  i `- Re: 80386 C compiler1Rosario19
26 Nov 24 i  `- Re: 80386 C compiler1Paul Edwards
25 Nov 24 `* Re: 80386 C compiler5Lynn McGuire
26 Nov 24  `* Re: 80386 C compiler4Keith Thompson
26 Nov 24   `* Re: 80386 C compiler3Lynn McGuire
26 Nov 24    `* Re: 80386 C compiler2Keith Thompson
26 Nov 24     `- Re: 80386 C compiler1BGB

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal