https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63837
--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- Thanks for the testcase. It seems that the GCC_COMPARE_DEBUG=0 uses a temporary file ./cc1 -quiet -iprefix /home/manuel/test1/217394M/build/gcc/../lib/gcc/x86_64-unknown-linux-gnu/5.0.0/ -isystem ./include -isystem ./include-fixed /dev/null -quiet -dumpbase null "-mtune=generic" "-march=x86-64" -auxbase null -Wpointer-sign "-fcompare-debug=-gtoggle" "-frandom-seed=0x6daada6b94b95048" "-fdump-final-insns=/tmp/cc3xSGvK.gkd" -o /tmp/cc3L00jg.s but the GCC_COMPARE_DEBUG=1 uses /dev/null: ./cc1 -quiet -iprefix /home/manuel/test1/217394M/build/gcc/../lib/gcc/x86_64-unknown-linux-gnu/5.0.0/ -isystem ./include -isystem ./include-fixed /dev/null -quiet -dumpbase null.gk "-mtune=generic" "-march=x86-64" -auxbase null -gtoggle -Wpointer-sign -w "-fcompare-debug=-gtoggle" -fcompare-debug-second -o /dev/null "-frandom-seed=0x6daada6b94b95048" "-fdump-final-insns=/tmp/ccMDEp8L.gk.gkd" which triggers the heuristic. I can simply ignore /dev/null when checking for input==output. I'm testing this patch: Index: gcc.c =================================================================== --- gcc.c (revision 217457) +++ gcc.c (working copy) @@ -4047,11 +4047,12 @@ process_command (unsigned int decoded_op read_cmdline_option (&global_options, &global_options_set, decoded_options + j, UNKNOWN_LOCATION, CL_DRIVER, &handlers, global_dc); } - if (output_file && strcmp (output_file, "-")) + if (output_file && strcmp (output_file, "-") + && strcmp (output_file, HOST_BIT_BUCKET)) { int i; for (i = 0; i < n_infiles; i++) if ((!infiles[i].language || infiles[i].language[0] != '*') && canonical_filename_eq (infiles[i].name, output_file)) Index: toplev.c =================================================================== --- toplev.c (revision 217457) +++ toplev.c (working copy) @@ -940,11 +940,12 @@ init_asm_output (const char *name) strcat (dumpname, ".s"); asm_file_name = dumpname; } if (!strcmp (asm_file_name, "-")) asm_out_file = stdout; - else if (!canonical_filename_eq (asm_file_name, name)) + else if (!canonical_filename_eq (asm_file_name, name) + || !strcmp (asm_file_name, HOST_BIT_BUCKET)) asm_out_file = fopen (asm_file_name, "w"); else /* Use fatal_error (UNKOWN_LOCATION) instead of just fatal_error to prevent gcc from printing the first line in the current file. */ fatal_error (UNKNOWN_LOCATION, If you can test it on your side, it would be helpful.