Search code examples
c++gdbeclipse-cdt

Eclipse loses source location when optimization reduced from -O2


Eclipse (Neon Milestone 2, CDT) can't locate main() in debug perspective when optimization is changed from -O2 in C++. Alternating between -O0 and -O2 consistently reproduces the problem. Eclipse is set to autogenerate makefiles.


Solution

  • This is a bug in eclipse CDT. I have filed a bug against eclipse CDT bugzilla see this. See this caution in CDT help guide.

    The only solution available now for this problem is to manually changing the debug launch configuration and re-configure and rebuild the project. So before debug verify the compiler options(Pass -g and -O0)