https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96230

            Bug ID: 96230
           Summary: driver: ICE in process_command, at gcc.c:5095
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: driver
          Assignee: unassigned at gcc dot gnu.org
          Reporter: z.zhanghaijian at huawei dot com
  Target Milestone: ---

For the case:

cat foo.c

void foo (void)
{
  return;
}

$gcc foo.c -S -dumpbase "" -dumpbase-ext .c -o foo.o

gcc: internal compiler error: in process_command, at gcc.c:5095
0x40ca3b process_command
        ../.././gcc/gcc.c:5095
0x41335b driver::set_up_specs() const
        ../.././gcc/gcc.c:8077
0x403b03 driver::main(int, char**)
        ../.././gcc/gcc.c:7885
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

I think we shoud consider the dumpbase is an empty string when with -S/-c.

Proposed patch:
diff --git a/gcc/gcc.c b/gcc/gcc.c
index c0eb3c10cfd..b8a9a8eada9 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -5086,7 +5086,7 @@ process_command (unsigned int decoded_options_count,
      extension from output_name before combining it with dumpdir.  */
   if (dumpbase_ext)
     {
-      if (!dumpbase)
+      if (!dumpbase || !*dumpbase)
        {
          free (dumpbase_ext);
          dumpbase_ext = NULL;

Any suggestions?

Reply via email to