Question
One of my pointer values is getting optimized out. How do I prevent this?
Posted on December 23, 2014 at 21:53
I'm stepping through my code to see where a certain bug occurs with my display driver, and found that something strange is going on. An instance of the class gets initialized properly, but once I try to use a method of that class, the pointer value seems to have been changed somehow.
I appear to initialize correctly...Display * volatile const sys_disp = new Display();
(gdb) p sys_disp $1 = (Display * const volatile) 0x20002638 ...but the value gets changed once I want to to use it.sys_disp->write_all_lines();
(gdb) p sys_disp $2 = (Display * const volatile) 0x0 Any ideas as to how I can keep the value the way it was? Why is this happening? I'll be happy to provide more debug output if necessary. #debug #volatile #optimizations