> Could you help me understand why this might be happening?
Presumably because you never used the global variable, so the compiler just optimised it out.