Internal Compiler Error

Robert Ennals rje33@cam.ac.uk
Tue Oct 13 17:14:00 GMT 1998


I have just been presented with the following output:


bash-2.01$ make
g++ -c  parsemain.c
parsemain.c: In method `struct
basic_string<char,string_char_traits<char>,__default_alloc_template<true,0>
>::Rep * basic_string<char,string_char_traits<char>,__default_alloc_template<true,0> >::rep() const':
parsemain.c:162: Internal compiler error.
parsemain.c:162: Please submit a full bug report to
`egcs-bugs@cygnus.com'.
make: *** [parsemain.o] Error 1   

g++ tells me it is egcs-2.90.29 980515 (egcs-1.0.3 release)

This is running under Linux.

Unfortunately the error does not appear to be repeatable.

Parsemain.c is attached in case that is useful. 
The only slightly unusual thing about it is that it is a C++ file with a
c filename (it used to be a C file and got changed without my having
bothered to change the filename yet).

It is part of an early version of a compiler for a weird little language
of mine. It currently tranlates to C++ and uses g++ as a back end.


-- 

Robert Ennals / Cambridge University / rje33@cam.ac.uk / ennals.acm.org
http://www.thor.cam.ac.uk/~rje33/

#include <string>
#include <list>

#include "parse_structs.h"
#include "oval.tab.h"
#include "stdio.h"
#include "stdlib.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
#include "unistd.h"


/*
 * -- Prototypes --
 */

void displaybanner();
void displayusage();
void yyerror(char* s);
void typecheck(ps_mod* in);
void generatecode(ps_mod* in);

/*
 * -- Externs --	
 */

extern int yyin;
extern int yyparse();
extern int oval_line_number;
extern int yydebug;

/*
 * -- Exported bits --
 */ 

ps_mod* module;



/*
 *	-- main --
 *
 * Main entry point for the parser.  Currently this is just used to do
 * parser tests. No type checking or code generation is done at the
 * moment.
 *
 */

void main(int argc, char** argv) 
{ 
  FILE* fd;

  displaybanner();

#ifdef DEBUG
  yydebug=1;
#endif

  if(argc != 2)
	{
	  displayusage();
	  exit(-1);
	}

  printf("Parsing file: %s\n",argv[1]);

  fd = fopen(argv[1], "r");
  if(fd == NULL)
	{
	  printf("FATAL ERROR: Could not open input file\n");
	  exit(-1);
	}

  yyin = (int)fd;

  int i = isatty(fileno(fd));

  int res = yyparse();
  
  if(res == 1)
	{
	  printf("Compilation failed. See error messages above for more information\n");
	  exit(-1);
	}
 
  printf("Parsing was successful\n");

   fclose(fd);

   printf("Type checking\n");

   typecheck(yylval.mod);

   printf("Type checking was successful\n - compiling with type checking disabled\n");

   printf("Generating code\n");

   generatecode(module);

   printf("Code generated successfully\n");

}

/*
 * -- typecheck --
 *
 * Typechecks the code and also works out a suitable set of offsets for members such as
 * to make offsets as low as possible while avoiding clashes if something needs to implement
 * several members with the same offset..
 */

void typecheck(ps_mod* in)
{
  printf("Type checking is not yet implemented\n");

  // DRAGONS: Not yet written
}

void generatecode(ps_mod* in)
{
  CodeOutput out;

  in->generatecode(&out);

  printf("Dumping code to stdout\n");


  FILE* body = fopen("out.cpp","rw");
  FILE* head = fopen("out.h","rw");

  out.headerout(stdout);
  out.bodyout(stdout);

  fclose(body);
  fclose(head);
}

void displaybanner()
{
  printf("-- Ovalcc 0.1 alpha -- \n(c)1998 Robert Ennals \n");
  printf("Experimental compiler for the Oval language \n");
  printf("Note that this is an incomplete implementation of the Oval language \n");
  printf("\n");
}

void displayusage()
{ 
  printf("USAGE: oval <file>\n");
  printf("Compiles an oval source file into C.\n");
  printf("This code can then be compiled with a C compiler to produce\n");
  printf("machine executable code.\n");
}

void yyerror(char* s)
{
  printf("error near line: %d\n",oval_line_number);
  printf("%s\n",s);
}




More information about the Gcc-bugs mailing list