[gnu.gcc.bug] BUG in GCC

pascal@ccvi.ccv.fr (Pascal Meheut) (11/16/89)

I think you may be interested in the following little program.

main(argc, argv)
	int	argc;
	char	**argv;
{
	for(argc--, argv++; argc; argc--, argv++) {
		switch(argv[0][1]) {
		case 'v':
			break;
		case 's':
			break;
		case 'f':
		case 'O':
		case 'g':
			break;
		default:
			printf("ignoring option %s\n", argv[0]);
		}
	}
	exit(0);
}

Compiled on a SUN sparc station 1, with gcc -o -O foo foo.c, and called with
'foo -s' it prints nothing which is correct.

But with gcc -O -fforce-mem -o foo foo.c, it prints "ignoring option -s"

I use gcc-1.35 and maybe the bug is fixed in gcc-1.36, but I have not enough
time to install it.
The problem do not appear with gcc-1.35 used on a SUN 3/50 or gcc-1.34.91 used
on a SUN-386.

I had found this bug in compiling X window (X11R3) on the sparc station. The
problem was with the program 'makedepend'.

I apologize for my bad english and hope you'll fix that bug quickly. (Perhaps
It's done, but I don't know what is the last version of gcc)

					Pascal Meheut.

rfg@ICS.UCI.EDU (12/08/89)

If you are using ansi prototype style for your function definitions
(manditory in C++) then it is possible that you may eventually come
across a prototyped function definition in which one or more of the
formal parameter names have been left out.  For example:

void quiet_File_error_handler(char*)
{
  errno = 0;
}

The example above comes from libg++ (1.36.1).  This is legal ansi (and C++)
but if you are using GCC 1.36 or G++ 1.36.1 with COFF and using -g, you
will get cc1 (or cc1plus) segfaulting on the example shown above.

The fix is simple, and is provided below.  (Your line numbers may vary.)

Enjoy,

// rfg

*** sdbout.c-	Tue Nov 28 23:37:01 1989
--- sdbout.c	Thu Dec  7 13:18:07 1989
***************
*** 1040,1044 ****
  	    }
  	  
! 	  name = IDENTIFIER_POINTER (DECL_NAME (parms));
  	  if (name == (char *)0 || *name == '\0')
  	    name = gen_fake_label ();
--- 1040,1044 ----
  	    }
  	  
! 	  name = DECL_NAME (parms) ? IDENTIFIER_POINTER (DECL_NAME (parms)) : 0;
  	  if (name == (char *)0 || *name == '\0')
  	    name = gen_fake_label ();