'asm_out_file' may be 'stdout', so need check this case before close it.
Or 'stdout' may be closed -- since need not open 'stdout', either need
not close it.

ChangLog:

  * topleve.c (finalize): Avoid to close 'asm_out_file' when it is
  'stdout'.

Signed-off-by: Chen Gang <gang.chen.5...@gmail.com>
---
 gcc/toplev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/toplev.c b/gcc/toplev.c
index 1c9befd..5fc11ae 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1878,7 +1878,7 @@ finalize (bool no_backend)
     {
       if (ferror (asm_out_file) != 0)
        fatal_error ("error writing to %s: %m", asm_file_name);
-      if (fclose (asm_out_file) != 0)
+      if (asm_out_file != stdout && fclose (asm_out_file) != 0)
        fatal_error ("error closing %s: %m", asm_file_name);
     }
 
-- 
1.7.11.7

Reply via email to