https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77497
Bug ID: 77497 Summary: Setting DWARF level and debug level together has flag-ordering-dependent results Product: gcc Version: 6.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: torne at google dot com Target Milestone: --- The -gdwarf-N option appears to confuse a previously set -gN debug level, and the intended interpretation of the options only applies if you set the DWARF level first. I compiled the same trivial source file with all combinations of -g[123] and -gdwarf-[34] in both parameter orders and the file sizes show the problem pretty clearly: -rw-r----- 1 torne eng 2412 Sep 5 18:04 test-g1-gdwarf-3.o -rw-r----- 1 torne eng 2384 Sep 5 18:04 test-g1-gdwarf-4.o -rw-r----- 1 torne eng 2412 Sep 5 18:04 test-g2-gdwarf-3.o -rw-r----- 1 torne eng 2384 Sep 5 18:04 test-g2-gdwarf-4.o -rw-r----- 1 torne eng 16648 Sep 5 18:04 test-g3-gdwarf-3.o -rw-r----- 1 torne eng 16620 Sep 5 18:04 test-g3-gdwarf-4.o -rw-r----- 1 torne eng 2268 Sep 5 18:04 test-gdwarf-3-g1.o -rw-r----- 1 torne eng 2412 Sep 5 18:04 test-gdwarf-3-g2.o -rw-r----- 1 torne eng 16648 Sep 5 18:04 test-gdwarf-3-g3.o -rw-r----- 1 torne eng 2248 Sep 5 18:04 test-gdwarf-4-g1.o -rw-r----- 1 torne eng 2384 Sep 5 18:04 test-gdwarf-4-g2.o -rw-r----- 1 torne eng 16620 Sep 5 18:04 test-gdwarf-4-g3.o In the cases where -g1 appears before the DWARF level it appears to be ignored and the exact same output as -g2 is generated. Weirdly this *doesn't* happen for -g3? This appears to have been introduced in gcc 4.9 (I can't repro in 4.8) and is still happening in 6.1.1. The docs don't appear to state that these flags are ordering-dependent, and in any case it's somewhat weird (especially that it doesn't affect -g3, only -g1).