On Thursday, April 26, 2001 I wrote: >The bug is related to the -MD option, which normally produces a file with extension .d holding >the dependencies for the compiled file. This option, as stated in the gcc sources, is deprecated and >will be removed at a later time; however, there's always some software that depends on it :-( > >When you specify -MD compiling, say, filename.c into filename, /usr/bin/gcc should translate -MD (by >means of the specs file) to > -M -MF filename.d -MQ filename >and pass these three options to cc1. What happens instead is that gcc emits > -M -MF filename.d -MQ .filename filename >and cc1 gets confused. > >The bug should be in gcc.c, maybe when parsing the "%o*" string from specs. I found no workaround >until now. The bug is indeed in gcc.c, around line 5250. There is code which should replace the extension in the output argument; however, when the output argument has no extension and no path separator, the counter goes to -1 and a dot is written outside the array bounds, with unpredictable results. It seems that only the expansion of -MD uses this code. Here is a patch, which avoids writing to arg[-1]. It is against gcc-20010430, but works also in the gcc-2.96 Mandrake uses: --- gcc.c Tue May 1 18:37:58 2001 +++ gcc.c Wed May 2 16:19:36 2001 @@ -5271,7 +5271,7 @@ do_spec_1 (" ", 0, NULL_PTR); if (suffix_subst) { - unsigned length = strlen (arg); + int length = strlen (arg); while (length-- && !IS_DIR_SEPARATOR (arg[length])) if (arg[length] == '.') @@ -5280,11 +5280,11 @@ break; } do_spec_1 (arg, 1, NULL_PTR); - if (!arg[length]) + if (length>=0 && !arg[length]) { ((char *)arg)[length] = '.'; - do_spec_1 (suffix_subst, 1, NULL_PTR); } + do_spec_1 (suffix_subst, 1, NULL_PTR); } else do_spec_1 (arg, 1, NULL_PTR); Alberto