patch for core dump in cse with -O2 on x86

Zack Weinberg zack@rabi.columbia.edu
Thu Oct 15 16:06:00 GMT 1998


On further investigation this is a deeper problem than I originally
thought.  I'm posting the testcase for someone to look at.

Without the patch I posted, the stage1 compiler dumps core in
equiv_constant.  With the patch, the stage1 compiler is fine but the
stage2 compiler dumps core in find_comparison_args, which suggests a
codegen bug somewhere.  I'm bootstrapping with egcs-1.0.3a.

Here's the test case.  It is a heavily simplified version of part of
cpplib.c.

zw

-- cut here --

struct cpp_buffer
  {
    unsigned char *cur;
    unsigned char *rlimit;
  };

struct cpp_options
  {
    char cplusplus_comments;
  };


struct cpp_reader
  {
    struct cpp_buffer *buffer;
    struct cpp_options *opts;
  };

int
skip_comment (pfile, linep)
     struct cpp_reader *pfile;
     long *linep;
{
  int c = 0;
  while (   ((pfile->buffer->cur < pfile->buffer->rlimit 
	      ? *pfile->buffer->cur : -1) == '\\')
	 && ((pfile->buffer->rlimit - pfile->buffer->cur >= 1
	      ? pfile->buffer->cur[1] : -1) == '\n'))
    {
      if (linep)
	(*linep)++;
      pfile->buffer->cur += 2;
    }

  if ((pfile->buffer->cur < pfile->buffer->rlimit
       ? *pfile->buffer->cur : -1) == '*')
    {
      pfile->buffer->cur += 1;
      for (;;)
	{
	  int prev_c = c;
	  c = pfile->buffer->cur < pfile->buffer->rlimit
	      ? *pfile->buffer->cur++ : -1;
	  if (c == -1)
	    return -1;
	  while (c == '\\' && (pfile->buffer->cur < pfile->buffer->rlimit
			       ? *pfile->buffer->cur : -1) == '\n')
	    {
	      if (linep)
		(*linep)++;
	      pfile->buffer->cur += 1;
	      c = pfile->buffer->cur < pfile->buffer->rlimit
		  ? *pfile->buffer->cur++ : -1;
	    }
	  if (prev_c == '*' && c == '/')
	    return ' ';
	  if (c == '\n' && linep)
	    (*linep)++;
	}
    }
  else if ((pfile->buffer->cur < pfile->buffer->rlimit
	    ? *pfile->buffer->cur : -1) == '/'
	   && pfile->opts->cplusplus_comments)
    {
      pfile->buffer->cur += 1;
      for (;;)
	{
	  c = pfile->buffer->cur < pfile->buffer->rlimit
	      ? *pfile->buffer->cur++ : -1;
	  if (c == -1)
	    return ' ';
	  while (c == '\\' && (pfile->buffer->cur < pfile->buffer->rlimit
			       ? *pfile->buffer->cur : -1) == '\n')
	    {
	      pfile->buffer->cur += 1;
	      c = pfile->buffer->cur < pfile->buffer->rlimit
		  ? *pfile->buffer->cur++ : -1;
	      if (linep)
		(*linep)++;
	    }
	  if (c == '\n')
	    {
	      pfile->buffer->cur += -1;
	      return ' ';
	    }
	}
    }
  else
    return '/';
}



More information about the Gcc-patches mailing list