From: ro@techfak.uni-bielefeld.DE (Rainer Orth)
Subject: g++ 2.2.2 ss-920925 crashes on extern "C" redeclarations
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 2 Oct 1992 10:24:31 GMT

When I tried to build libg++ 2.2 with g++ 2.2.2 ss-920925 on a SPARCstation
ELC running Solaris 2.0, the compiler crashed on some files:

libg++/src/{Integer, Rational, Complex, Fix, CursesW}.cc:

gcc: Internal compiler error: program cc1plus got fatal signal 11 

The problem could be reduced to a minimal test case:

----- redecl.ii --------------------------------------------------------------
extern void m();
extern "C" void m();
------------------------------------------------------------------------------

ro@efeu 1448 > gcc -v -c redecl.ii
Reading specs from /vol/gnu/lib/gcc-lib/sparc-sun-solaris2.0/2.2.2/specs
gcc version 2.2.2
 /vol/gnu/lib/gcc-lib/sparc-sun-solaris2.0/2.2.2/cc1plus redecl.ii -quiet -version -o /tmp/cca0045w.s
GNU C++ version 2.2.2 (sparc) compiled by GNU C version 2.2.2.
gcc: Internal compiler error: program cc1plus got fatal signal 11

Running gdb on cc1plus shows that the decl.lang_specific member of olddecl
isn't properly initialized in cp-decl.c (duplicate_decls).

(gdb) run redecl.ii
Starting program: /volumes/gnu/src/gcc-2.2.2-920925/cc1plus redecl.ii

Program received signal 11, Segmentation fault
0x2e304 in duplicate_decls (newdecl=0x1c7ae0, olddecl=0x1c7a78)
    at ../cp-decl.c:1966
(gdb) list
1961	duplicate_decls (newdecl, olddecl)
1962	     register tree newdecl, olddecl;
1963	{
1964	  extern struct obstack permanent_obstack;
1965	  unsigned olddecl_uid = DECL_UID (olddecl);
1966	  int olddecl_friend = DECL_LANG_SPECIFIC (olddecl) && DECL_FRIEND_P (olddecl);
1967	  int types_match;
1968	  int new_defines_function;
1969	  register unsigned saved_old_decl_uid;
1970	  register int saved_old_decl_friend_p;
(gdb) p olddecl
$12 = (union tree_node *) 0x1c7a78
(gdb) pt
 <tree_list 1c7a78
    type <lang_type 1bba18 unknown type type <lang_type 1bba18 unknown type>
        permanent VOID
        size <integer_cst 1b98f8 constant permanent 0
        align 1 symtab 0
        pointer_to_this <lang_type 1bba18 unknown type> reference_to_this <lang_type 1bba18 unknown type>
    permanent
    purpose <identifier_node 1c79a0 m permanent tree_0 global <tree_list 1c7a78>
    value <function_decl 1c7a00 m
        type <function_type 1bc548 type <void_type 1b9928 void>
            permanent DI
            size <integer_cst 1b88b8 constant permanent 64
            align 64 symtab 0
            arg-types <tree_list 1b99d8 unsigned permanent value <void_type 1b9928 void>
        permanent public external decl_4 SI file redecl.ii line 1
       
        decl-main-variant 1c7a00
        (mem:SI (symbol_ref:SI ("m__Fv")))
        chain <var_decl 1bce38 __PRETTY_FUNCTION__ type <array_type 1b9b80>
            readonly used permanent static ignored in_system_header BLK file <built-in> line 0
            size <integer_cst 1b9c00 constant permanent 2048
            align 8 initial <string_cst 1bce90>
            (mem/s/u:BLK (symbol_ref:SI ("__PRETTY_FUNCTION__"))) chain <var_decl 1bcd70 __FUNCTION__>
(gdb) p (*(struct tree_decl *)olddecl).lang_specific
$14 = (struct lang_decl *) 0x1c600000
(gdb) p *$14
$15 = Cannot access memory at address 0x1c600000.

-----------------------------------------------------------------------------
Rainer Orth, Technical Computer Science, University of Bielefeld

Internet: ro@TechFak.Uni-Bielefeld.DE



Newsgroups: gnu.g++.bug