Checking against NULL will be eliminated?

Carl Banks pavlovevidence at gmail.com
Thu Mar 3 22:16:38 EST 2011


On Mar 3, 7:12 pm, Carl Banks <pavlovevide... at gmail.com> wrote:
[snip]

Accidental post before I was done.  To complete the thought:

I actually can think of one indeterminate behavior in C (although it's
not certain whether this qualifies as interaction with the
environment):

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

The C standard allows the memory a refers to to be uninitialized,
meaning that a's value is whatever previously existed in that memory
slot, which could be anything.

OTOH this program:

int main(void) {
    int a = 1;
    a = a++;
    printf("%d\n",a);
    return 0;
}

is undefined, which I guess technically could mean that compiler could
output an indeterminate result, but I doubt there are any compilers
that won't output the same value every time it's run.


Carl Banks



More information about the Python-list mailing list