This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix cpp ICE (regression from 2.95.x or 3.0.4)


Commands like:
echo '#include <stdio.h>' | gcc3 -E -dD -M -
echo '#include <stdio.h>' | gcc3 -E -dI -M -
echo '#include <stdio.h>' | gcc3 -E -dN -M -
echo '#include <stdio.h>' | gcc3 -E -dM -dD -

(or equally if - is replaced with regular file) cause

gcc3: Internal error: Segmentation fault (program cpp0)
Please submit a full bug report.
See <URL:> for instructions.

The problem is that all of -dI, -dN and -dD require no_output to be zero
(e.g. with -dD -M the crash is because cb_define calls maybe_print_line
while is 0).

I've checked egcs 1.1.2 and gcc 2.95.x and only -dM -M shows some
output in addition to the makefile rules, -dD -M, -dI -M and -dN -M
all show just the makefile rule, (gcc 3.0.x x <= 4 doesn't print anything
for -dM -M either).

The following patch fixes it by doing what gcc <= 2.95.x did, ie.
silently disable -dM, -dI and -dN when -M or -MM is given, plus
only uses the last of -dM, -dD and -dN options given on the command line
(this doesn't match what gcc <= 2.95.x did, but IMHO it makes most sense,
<= 2.95.x wouldn't output anything for -dM -dD, 2.96-RH and 3.0.x x<=4
would print weirdo output containing lines like
# 24 "(null)"(null)
and current 3.1 was ICEing).

Ok to commit?
Mark, is this ok for branch too?

2002-05-01  Jakub Jelinek  <>

	* cppinit.c (cpp_handle_option) [-dM]: Don't set no_output here...
	(cpp_post_options): ...but here.  Disable -dD, -dN and -dI when
	-M -or -MM is in effect.

--- gcc/cppinit.c.jj	Tue Mar 26 17:54:46 2002
+++ gcc/cppinit.c	Wed May  1 12:31:41 2002
@@ -1554,7 +1554,6 @@ cpp_handle_option (pfile, argc, argv, ig
  		case 'M':
 		  CPP_OPTION (pfile, dump_macros) = dump_only;
-		  CPP_OPTION (pfile, no_output) = 1;
 		case 'N':
 		  CPP_OPTION (pfile, dump_macros) = dump_names;
@@ -1821,6 +1820,21 @@ cpp_post_options (pfile)
   if (CPP_OPTION (pfile, preprocessed))
     pfile->state.prevent_expansion = 1;
+  /* -dM makes no normal output.  This is set here so that -dM -dD
+     works as expected.  */
+  if (CPP_OPTION (pfile, dump_macros) == dump_only)
+    CPP_OPTION (pfile, no_output) = 1;
+  /* Disable -dD, -dN and -dI if we should make no normal output
+     (such as with -M). Allow -M -dM since some software relies on
+     this.  */
+  if (CPP_OPTION (pfile, no_output))
+    {
+      if (CPP_OPTION (pfile, dump_macros) != dump_only)
+	CPP_OPTION (pfile, dump_macros) = dump_none;
+      CPP_OPTION (pfile, dump_includes) = 0;
+    }
   /* We need to do this after option processing and before
      cpp_start_read, as cppmain.c relies on the options->no_output to
      set its callbacks correctly before calling cpp_start_read.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]