Re: Atomic operations in 32 and 64 bit platforms



Rod Pemberton wrote:
"H. Peter Anvin" <hpa@xxxxxxxxx> wrote in message
news:488FBE95.6040104@xxxxxxxxxxxx
Rod Pemberton wrote:
And, parameter passing order is also an evaluation.
No, it's not. The C compiler is perfectly free to generate the
parameters in any order ..., as long as it (a) ends
up in the right order in the end, and (b) doesn't violate sequence points.

How exactly does the inanimate compiler "decide" what order that is? (It's
programmed by a programmer after he/she made a decision about what order
should be used under what circumstances.) And, how can you not call the
resulting decision about that order an evaluation?

That's not exactly true, as frequently the order is decided by the scheduler inside the compiler and can be different for each instance, but let me rephrase this to perhaps make you happier:

"The author of the compiler can pick whatever order he believes is better."

What that means is that if you do something like this:

#include <stdio.h>

static int foo(void)
{
static int n = 0;
return ++n;
}

int main(void)
{
printf("%d %d\n", foo(), foo());
return 0;
}

.... you could get either "1 2" or "2 1" output; either is legal.

-hpa
.



Relevant Pages

  • Re: Newbie question - displaying trivia questions at random
    ... and use some C++ compiler, ... static int num_items =0; ... Will not compile because syntax error. ... Visit http://www.ecomstation.de the home of german eComStation ...
    (comp.lang.c)
  • Re: Atomic operations in 32 and 64 bit platforms
    ... The C compiler is perfectly free to generate the ... How exactly does the inanimate compiler "decide" what order that is? ... programmed by a programmer after he/she made a decision about what order ... but you've got no problem indicating you believe ...
    (alt.lang.asm)
  • [PATCH][kprobe]replace magic numbers with enum (Re: Warning in kprobes.c)
    ... powerpc compiler is more unforgiving than most other arch compilers. ... Here is a patch which uses an enum to express the slot status. ... static int collect_garbage_slots; ...
    (Linux-Kernel)
  • Re: const and constant expression
    ... test.c:4: error: initializer element is not constant ... Can someone point me to text that says that 'const' is not 'constant ... Is the compiler correct after optimisation? ...
    (comp.lang.c)
  • Re: global constant variables in mex
    ... I did this (both before my original post and retried after reading ... The thing I'm surprised about is that the compiler doesn't recognize ... subsequently declared as a global constant. ...
    (comp.soft-sys.matlab)