Just looking at the code doesn't give any clue about your intent; could you describe step by step what you think the program does and why?

Do you have optimisations switched off? It's possible the compiler might think glob_temp_var hasn't changed and therefore print out the same value it printed before, rather than generating code to go back to memory and actually take a look. You may need to define glob_temp_var volatile.