Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


#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