https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89514
Bug ID: 89514 Summary: -g -fdebug-types-section -flto gives 'Dwarf Error: bad length' in gdb Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: gcc at mailinator dot com CC: marxin at gcc dot gnu.org Target Milestone: --- #include <iostream> int main() { std::cout << "Hello, World!"; return 0; } g++ hello_world.cc -g -fdebug-types-section -flto -o hello_world gdb hello_world Then GDB 7.11.1, 8.1, 8.2 reports: Dwarf Error: bad length (0xe7) in compilation unit header (offset 0x1e3a + 0) For larger binaries GDB reports a corrupted dwarf version: Dwarf Error: wrong version in compilation unit header (is 3745, should be 2, 3, or 4) Reproduced on GCC 8.1, 8.2, 8.3 with Binutils 2.30 and Binutils 2.32. At first I suspected Binutils, then GDB, but I think this is a GCC issue, since -fdebug-types-section works with -fwhole-program, but not -flto.