Skip to content

Instantly share code, notes, and snippets.

@sonney2k
Created July 20, 2013 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonney2k/6046331 to your computer and use it in GitHub Desktop.
Save sonney2k/6046331 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <atomic>
int main(int argc, char** argv)
{
volatile std::atomic<int> x;
volatile int i;
for (i=0; i<100000000; i++)
{
x.store(i);
}
printf("%d %d\n", x.load(), sizeof(x));
}
#include <stdio.h>
int main(int argc, char** argv)
{
volatile int x;
volatile int i;
for (i=0; i<100000000; i++)
{
x=i;
}
printf("%d %d\n", x, sizeof(x));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment