Content originally posted in LPCWare by jdurand on Thu Sep 26 10:43:31 MST 2013
Thanks for pointing to the list in help, it looks like you've actually done a pretty good job of fleshing out the help file. That's unusual.
Anyway, I may have missed it but I didn't see an option to NOT assume any variable is a constant (essentially treat every variable as volatile without having to tag every one and then deal with the warnings). I have no problem with a variable being moved around between static memory, stack, and registers. My issue comes where I change a variable in one part of a function and find it no longer has any effect later on because the compiler thought it was a constant and tossed it.
In the case I mentioned, I read a structure from EEPROM and then act on the data in the structure. The compiler tossed the whole structure which sort of makes the program pointless.
Marking all my variables VOLATILE has fixed it, so I'll just keep that in mind when I need to use optimization.