This is a blog about me, Seinfeld, okonomiyaki, japanese toilet seats, and other things of interest

Tuesday, February 17, 2009

Fun with C

Consider the following little program:

int main()
{
int x[10];
int i;

for (i=0; i <= 10; i++){
x[i] = 0;
}
return 0;
}

What happens if you compile without optimization?
gcc -o t t.c
Think about it before you actually run it! What is the difference if you compile with optimization in gcc?
gcc -o t t.c -O1

1 Comments:

Anonymous Anonymous said...

Depends on the way the compiler allocates the variables on the stack and whether the compiler performs any optimizations, such as loop unrolling.

2:56 PM

 

Post a Comment

<< Home