Should ALL global variables be volatile-qualified?
问题 In this example, does correctness require global_value to be declared volatile ? int global_value = 0; void foo () { ++ global_value; } void bar () { some_function (++global_value); foo (); some_function (++global_value); } My understanding is that volatile is "intended" for pointers to mapped memory and variables which can be modified by signals (and emphatically not for thread-safety) but it's easy to imagine that bar might compile to something like this: push EAX mov EAX, global_value inc