On Mon, Mar 19, 2007 at 07:17:46PM -0700, Darrin Chandler wrote:
> On Mon, Mar 19, 2007 at 07:12:24PM -0300, Gustavo Rios wrote:
> > I am writing a very simple program but the output change for the c
> > variable value change every time i run it. What would it be my mistake
> > on the source? Did i forget some thing?
> > 
> > #include <stdio.h>
> > 
> > int
> > main(int argc, char **argv)
> > {
> >        unsigned long long      x, c;
> >        unsigned                *p;
> > 
> >        x = 1, x+= (unsigned long long)1 << 33 ;
> >        p = (void *)&x;
> >        c = p[0] * p[1];
> > 
> >        fprintf(stdout, "x:%llu\n", x);
> >        fprintf(stdout, "0,1:%u,%u\n", p[0], p[1]);
> >        fprintf(stdout, "c:%llu\n", c);
> > 
> >        return 0;
> > }
> 
> I run this many times, with other stuff in between, and I always get:
> 
> $ ./gustavo 
> x:8589934593
> 0,1:1,2
> c:2
> 
> Same values for everything, every time. Hmm.

Compile it with -O3. Then enjoy.

Reply via email to