Im working on a large code base which is now being compiled using gcc11 O3. Behaviour in certain parts of the code differs from when it was being used with gcc9 O3. When i try to print out the affected portion, optimizations change and I'm unable to see the bug anymore. Are there any steps i can follow to find out the bugs of this type ?
EDIT:- Found the problem. As pointed out by Stefan in the comments, it was an undefined behaviour. Was being caused by strict-aliasing issues. But it is certainly very hard to figure out.