In the end, your compiled code is not working as you want. It is very unlikely that you can fix bugs in the compiler, so you need to change your source code until you have compiled code that works the way you want.
In a situation where you have obviously correct code that doesn’t work and non-obvious code that works, please add a strongly worded comment. Otherwise the next programmer says “this code is stupid and clumsy, I’ll fix it” and recreates the code that is compiled incorrectly.
Now is the compiler at fault? 99% of the time it isn’t. Most important, check for “undefined behaviour”. The behaviour of your code is undefined if the C or C++ Standard says so. “Undefined behaviour” means anything can happen not just things that you would find reasonable. With undefined behaviour, anything the compiler does is correct by definition. Then there is “unspecified behaviour”. There are multiple defined behaviours but the compiler doesn’t tell you which one it uses. What it uses may be unexpected to you but is valid. And there is “implementation defined behaviour”, where every C or C++ compiler must define the behaviour. If you switch compilers, “implementation defined” behaviour can change.
To find if a problem is the compiler’s fault, you need to examine your code very carefully to see if it is correct. If you are 100% sure your code is correct then you can blame the compiler. What do you do then? Find out who maintains the compiler. Try to find the simplest code possible that demonstrates the compiler bug. Then send a bug report to the maintainer of the compiler and hope they fix the problem.