Comment on What Every C Programmer Should Know About Undefined Behavior #1/3parentComments−Peaker15yI had a similar bug. Using a tracing framework of macros, I had something like: #define TRACE_FOO(foo_ptr) TRACE_INT((foo_ptr)->x) ... TRACE_ENTER(TRACE_INT(x) TRACE_FOO(foo_ptr)); if(!foo_ptr) return NULL; use foo-ptr The NULL check was optimized out. The dereference of foo_ptr was hidden behind TRACE_FOO, which made it even harder to spot. I spent hours on that one :-)
Comments
I had a similar bug. Using a tracing framework of macros, I had something like:
The NULL check was optimized out. The dereference of foo_ptr was hidden behind TRACE_FOO, which made it even harder to spot. I spent hours on that one :-)