🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1594

GCC 2.3.3 (MIPS): inline bug

#1594
From: simon
Date: Wed, 06 Jan 1993 21:20
89 lines
3272 bytes
liasg1[gcc-2.3.3]% gcc -v
Reading specs from /logiciels/public/gnu/lib/gcc-lib/iris4d/2.3.3/specs
gcc version 2.3.3

Somebody complained that the C++ side of GCC 2.3.3 didn't work on the
Silicon Graphics, and I found out that cc1plus dumped core during
initialization.  The gcc installation has been bootstrapped properly;
a cc1plus that has just been compiled with SGI's standard CC seems to
work fine.

Here's what GDB says:

----------------------------------------------------------------------
liasg1[gcc-2.3.3]% gdb cc1plus
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.7, Copyright 1992 Free Software Foundation, Inc...
Breakpoint 1 at 0x55ce48: file abort.c, line 36.
(gdb) r
Starting program: /usr/tmp/gcc-2.3.3/cc1plus

Program received signal 11, Segmentation fault
0x43b170 in init_lex () at cp-lex.c:756
756           UNSET_RESERVED_WORD ("exception");
(gdb) bt
#0  0x43b170 in init_lex () at cp-lex.c:756
During symbol reading, guessed tag type of struct sigaction incorrectly.
#1  0x46caec in compile_file (name=0x1003944c "stdin") at toplev.c:1535
#2  0x46fcf0 in main (argc=1, argv=0x7fffc754, envp=0x65) at toplev.c:3285
(gdb)
----------------------------------------------------------------------

The problem seems to be related to inlining - UNSET_RESERVED_WORD
calls is_reserved_word which is declared inline.

Here's a smaller example that demonstrates the bug.  It runs fine when
compiled without -O, but dumps core in the same statement as above
when compiled with -O ("gcc -I. -I. -I./config -O foo.c" in the top
gcc source directory):

------------------------------ foo.c ------------------------------
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <setjmp.h>
#include "config.h"
#include "input.h"
#include "tree.h"
#include "cp-lex.h"
#include "cp-parse.h"
#include "cp-tree.h"
#include "flags.h"
#include "obstack.h"

#ifdef MULTIBYTE_CHARS
#include <stdlib.h>
#include <locale.h>
#endif

#include "cp-hash.h"

#ifndef errno
extern int errno;		/* needed for VAX.  */
#endif
extern jmp_buf toplevel;

#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free

extern struct obstack *expression_obstack, permanent_obstack;
extern struct obstack *current_obstack, *saveable_obstack;

extern double atof ();

extern char *get_directive_line ();	/* In c-common.c */

extern int
main ()
#define UNSET_RESERVED_WORD(STRING) \
  do { is_reserved_word (STRING, sizeof (STRING) - 1)->name = ""; } while (0)

{
  UNSET_RESERVED_WORD ("all");
  UNSET_RESERVED_WORD ("except");
  UNSET_RESERVED_WORD ("exception");
  return 0;
}
------------------------------ foo.c ------------------------------
Technical Details
Message-ID: <m0n9iBA-0009VdC@liasg1.epfl.ch>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!lia.di.epfl.CH!simon

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!lia.di.epfl.CH!simon
From: simon@lia.di.epfl.CH
Subject: GCC 2.3.3 (MIPS): inline bug
Message-ID: <m0n9iBA-0009VdC@liasg1.epfl.ch>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 6 Jan 1993 21:20:00 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 91