Debug question.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LostTemplar
    Knight
    • Aug 2009
    • 670

    Debug question.

    Question to C veterans.
    How to debug a bug, that only appears with -O2 option.
    GDB only works without optimization, but in this case there is no bug.

    Also the bug is old, it appears not after code change, but after GCC and clib version upgrade.
  • debo
    Veteran
    • Oct 2011
    • 2402

    #2
    So, this is awful, and I have dealt with it differently at different times. I've had some luck with using valgrind in some cases, although sometimes the instrumentation it does ends up quashing the bug. Sometimes i've also used the -fno-X switches to turn off optimizations one at a time, to see if I can get some idea of why it might be happening.

    I've heard people say on Windows that this isn't as hard, but I've never written C/C++ that wasn't gcc before
    Glaurung, Father of the Dragons says, 'You cannot avoid the ballyhack.'

    Comment

    • LostTemplar
      Knight
      • Aug 2009
      • 670

      #3
      Actually fixed, but it was a nice experience, how such a bug could exist for so long unnoticed and finally cause a problems after compiler update. Code was simply accessing a wrong array.

      Comment

      Working...
      😀
      😂
      🥰
      😘
      🤢
      😎
      😞
      😡
      👍
      👎