GDB behaves like any other debugger when it comes to optimized versus unoptimized builds. Debugging an optimized build is possible in any debugger, but your debugging information no longer maps exactly to compiler output, making source-level debugging harder.