The code is in an ISR? It should volatile.
Alexander.
Not necessarily. You only need volatile if you are checking a variable in a loop. Like while (var_used_in_an_interrupt!=different_value) {keep_waiting();}; If you do the actual polling from a function you probably won't need volatile at all but a caveat can be that a function is inlined into the calling function. This will depend on the optimisation settings. Basically you need to know at which point a variable is read from memory into a register to determine whether you need volatile or not.
You
probably won't need voltaile? What kind of broken engineering strategy is that? This is how we end up with so many wrong bug reports against compilers. "It works OK with optimisation off, but fails with optimisation on, so your compiler is broken. Fix it.". Its amazing how much broken codes works OK until a new version of the compiler comes out, ups the game in optimisation, and makes the code behave as badly as it was written.
I've seen open source projects rally around the idea that a broken GCC means some aspect of the code doesn't work, and this idea persists for years unquestioned. Then you look at the code one day, to wile away some time, make a couple of minor changes to tighten up things like the use of volatile, and suddenly the code works. Then, half the people STILL say it was the compiler at fault.