I'm creating this multithreaded C++ program and upon compiling in Release mode, I'm finding bugs of the sort (object still null) ie, it looks like missing volatile
markers.
But the problem is, since there is a 2nd worker thread touching all kinds of objects, it means that virtually everything is volatile in the program.
I'm wondering if there is a way to turn off optimizations in the Apple LLVM compiler that create the bugs the volatile
keyword was specifically designed to fix. These bugs don't show up in debug mode (because optimizations are off). Putting volatile
everywhere basically means peppering every class with volatile
after every member function, and adding volatile
before every shared variable declaration.
I think I'd rather lose that volatile
optimization than risk a spurious bug showing up because I forgot to mark something volatile
.