c - Why doesn't compiler remove the useless loop? -


if have code such as

int main() {     int i, j, k;     int sum = 1;      (i = 0; < size; i++) {         (j = 0; j < size; j++) {             (k = 0; k < size; k++) {                 sum = -sum;             }         }     }      printf("hello, world\n");      return 0; } 

the optimize code still appears going through loops. why doesn't compile remove because doesn't affect print or return statements?

it appears gcc remove long specify -o2

gcc -wall -o2 

i compiling (no optimization)

gcc -wall  

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -