I have the following code:
#include <iostream>
using namespace std;
class A {
public:
A() { a.a = a.b = 1; }
struct { int a, b; } a;
int b(void);
};
int A::b(void) {
int x = a.a; a.a = a.b; a.b = x; return x;
}
int main(void) {
A a;
a.a.a = 0;
a.b();
cout << a.b() << a.a.b << endl;
return 0;
}
I am getting different result when running in debug mode and in release mode. In release mode i get 11, while in debug mode i get 10. What is causing this output difference? I'm using visual studio 2017.