Hello all,
During the testing of a large application I am maintaining I came across a segfault which only occured on newer versions of gcc and only with an -O2 optimization level. I tried to debug it.

However -O2 optimizaion doesnt allow access to some variables because they are optimized out. So i went around the old fashion way(prints). Somewhere along the execution a pointer got meddled with and changed value. Unfortunatelly that happens inside a very big function call in which i cant monitor the value of the pointer to see where it changes.

Here is the really anoying part: if i so much as touch the &pointer to monitor it, the value never changes an the program runs correctly.

Any ideas on how to go about debugging this?

Thank you!