This is my code(removed some unreleated parts though):
#include <atomic>
#include <math.h>
#include <iostream>
using namespace std;
struct Profiler
{
private:
Profiler() {}
Profiler(const Profiler& other) {}
Profiler operator = (const Profiler& other) { return *this; }
public:
static atomic_ullong a;
static atomic_ullong b;
};
atomic_ullong Profiler::a = { (unsigned long long)0 };
atomic_ullong Profiler::b = { (unsigned long long)0 };
bool func()
{
Profiler::a++;
float det = rand();
if (abs(det) < numeric_limits<float>::epsilon())
return false;
Profiler::b++;
return true;
}
int main(int argc, char** argv)
{
bool result = func();
cout << result << endl;
system("pause");
return 0;
}
It compiles and runs well under debug mode. However, after I switch to release mode, I keep getting access violation exceptions when it runs. It's so weird that it runs without a problem if I change atomic_ullong to atomic_ulong or atomic_uint. But the length of those two is just not enough. So anyone know why this is happening and how to solve it? Please help!