• Create Account

### #Actualultramailman

Posted 06 April 2013 - 05:20 PM

In the above code, is gcc free to do something like : "hey, increment takes a generic_list_t*, so nothing is messing with the 'x' value, so when increment returns, I won't bother to dereference some_int again, and I'll just say that after_increment is the same as before_increment, optimize out the after_increment variable, and just call printf with two before_increments" ?

Ah, that does sound like a resonable optimization. I guess you could qualify the variable as "volatile", then that should disable optimizations for that variable.
volatile int_t some_int;

That's still a work around though, no idea how to reconcile the way you wanted.

### #1ultramailman

Posted 06 April 2013 - 05:19 PM

In the above code, is gcc free to do something like : "hey, increment takes a generic_list_t*, so nothing is messing with the 'x' value, so when increment returns, I won't bother to dereference some_int again, and I'll just say that after_increment is the same as before_increment, optimize out the after_increment variable, and just call printf with two before_increments" ?

Ah, that does sound like a resonable optimization. I guess you could qualify the variable as "volatile", then that should disable optimizations for that variable.

That's still a work around though, no idea how to reconcile the way you wanted.

PARTNERS