Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why doesn't this end

Name: Anonymous 2010-10-31 5:35

#include <stdio.h>

main()
{

    int a;

while(a != 256)
    {putchar(a);
    a++;}
}

But if I add  a = 0;  after int a;, it ends fine?

Something to do with a variable not being initialized properly, and therefore, not being able to be compared or something?

Compiled with Code::Blocks+GCC or mingw or something. The debugger also reports no relevant issues with the initial code.

Name: Anonymous 2010-10-31 11:09

>>40
yhbt

Name: Anonymous 2010-10-31 13:38

>>41
Motherfucker.

Name: Anonymous 2010-10-31 15:45

Maybe a has a value greater than 256?
IT IS A MYSTERY

Name: Anonymous 2010-10-31 16:19

>>43
Maybe PAY ATTENTION TO THE THREAD GODDAMN

Name: Anonymous 2010-10-31 18:59

yhl yhbt hand

Name: Anonymous 2010-10-31 20:14

Relevant parts of the latest C99 standard (n1256.pdf) regarding uninitialized automatic storage duration objects:

6.7.8p10: If an object that has automatic storage duration is not initialized explicitly, its value is indeterminate.

3.17.2 (definition of indeterminate value): Either an unspecified value or a trap representation.

3.17.3 (definition of unspecified value): Valid value of the relevant type where this International Standard imposes no requirements on which value is chosen in any instance. NOTE An unspecified value cannot be a trap representation.

6.2.6.1p5 (definition of trap representation): Certain object representations need not represent a value of the object type. If the stored value of an object has such a representation and is read by an lvalue expression that does not have character type, the behavior is undefined. If such a representation is produced by a side effect that modifies all or any part of the object by an lvalue expression that does not have character type, the behavior is undefined.41) Such a representation is called a trap representation.

Footnote 41: Thus, an automatic variable can be initialized to a trap representation without causing undefined behavior,but the value of the variable cannot be used until a proper value is stored in it.

Name: Anonymous 2010-11-01 0:22

>>46
Thanks, Zhivago.

Name: Anonymous 2010-11-14 23:31

Name: Anonymous 2011-02-04 19:10


Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List