From: rrh@tera.com (Robert R. Henry)
Subject: g++2.3.2 fatal error (yyparse calls chainon calls abort)
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 14 Dec 1992 23:11:26 GMT

For the program at the bottom of this note,
one gets a fatal signal from cc1plus.
never mind that the program may be syntactically or semantically mangled.

It topples over in chainon called from yyparse.

Reading specs from /usr/local/lib/gcc-lib/sparc-sun/2.3.2/specs
gcc version 2.3.2
 /usr/local/lib/gcc-lib/sparc-sun/2.3.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__CPLUSPLUS20__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix foo.c /usr/tmp/cca09886.i
ld.so: warning: /usr/lib/libc.so.1.7 has older revision than expected 8
GNU CPP version 2.3.2 (sparc)
 /usr/local/lib/gcc-lib/sparc-sun/2.3.2/cc1plus /usr/tmp/cca09886.i -quiet -dumpbase foo.cc -version -o /usr/tmp/cca09886.s
ld.so: warning: /usr/lib/libc.so.1.7 has older revision than expected 8
GNU C++ version 2.3.2 (sparc) compiled by GNU C version 2.3.2.
/usr/local/bin.new/gcc: Internal compiler error: program cc1plus got fatal signal 6

typedef long long int int64;
typedef long long unsigned int u_int64;
typedef char *charP;
typedef int IntrinsicId;

typedef class OpN *OpNP;
typedef class DDE *DDEP;
typedef class PDG *PDGP;
typedef class MemAccessN *MemAccessNP;
typedef class ConstN *ConstNP;

typedef enum boolean {TRUE,FALSE};
class OptLower {
  private:
    static boolean sequence_point_between_ops(OpNP op1, OpNP op2, PDGP g); 
    static DDEP keep_latest_edge(DDEP old_e, DDEP new_e, OpNP op);
    static boolean matching_subtree(PDGP g, OpNP op1, OpNP op2);
    static void rewrite_load_as_fetch_add(PDGP g, MemAccessNP load,
			 MemAccessNP store, OpNP add, OpNP fetchadd_parent,
			 OpNP addend, boolean duplicate_addend,
			 boolean move_load_after_addend);
    static void rewrite_load_as_fetch_add(PDGP g, MemAccessNP load,
			  MemAccessNP store, OpNP add, OpNP fetchadd_parent,
			  OpNP addend, boolean duplicate_addend);
    static void constant_div(OpNP op, PDGP g, ConstNP denom);
    static int64 bit_left_zeros(int64 tZ);

  public:
    static void subscript(OpNP op, PDGP g);
    static void call(OpNP op, PDGP g);
    static void store(OpNP op, PDGP g);
    static void arrayaddr(OpNP op, PDGP g);
    static void div(OpNP op, PDGP g);
    static void minmax(OpNP op, PDGP g);

    static int64 uns_recip(int64 y);
    static int64 int_recip(int64 y);
    static int64 int_recip_table(unsigned i);
    static int64 uns_recip_shift(int64 tZ);
    static int64 int_recip_shift(int64 tZ);
};

enum CT_type_enum {red};
enum OpM_type_enum {blue};

class IntrinsicF {
  public:
    static IntrinsicId NO_ID;
    const CT_type_enum NO_TEMPLATE = (CT_type_enum)-1;
    const OpM_type_enum NO_OPM = (OpM_type_enum)-1;
const int ARG_BLOCK_id = 0;

int64 OptLower::bit_left_zeros(int64 tZ) {
    int cnt = 0;

    if (tZ == 0) {
	tZ = 64;
    } else {
	while (tZ >= 0) {
	    ++cnt;
	    tZ <<= 1;
	}
	tZ = cnt;
    }
    return tZ;
}



int64 OptLower::uns_recip(int64 y) {
    int64 q, r;
    int i;

    r = ((int64)1) << 63;
    while (y >= 0)
      y <<= 1;

    for (i = 64; i >= 0; --i) {
	q <<= 1;
	if (r < 0) {
	    r <<= 1;
	    r -= y;
	    q += 1;
	} else {
	    r <<= 1;
	    if ((uint64)r >= (uint64)y) {
		r -= y;
		q += 1;
	    }
	}
    }
    if (r != 0) {
	q += 1;
    }
    return q;
}

int64 OptLower::int_recip(int64 y) {
    int64 q, r;
    int i, neg;
    neg = y < 0;
    if (neg)
      y = -y;

    r = ((int64)1) << 63;
    while (y >= 0)
      y <<= 1;

    for (i = 63; i >= 0; --i) {
	q <<= 1;
	if (r < 0) {
	    r <<= 1;
	    r -= y;
	    q += 1;
	} else {
	    r <<= 1;
	    if ((uint64)r >= (uint64)y) {
		r -= y;
		q += 1;
	    }
	}
    }
    if (r != 0) {
	q += 1;
    }
    if (!neg == (q != 0)) {
	r = ((int64)1) << 63;
	q -= r;
    }
    return q;
}
int64 OptLower::int_recip_table(unsigned i) {
    int64 recip;
    if (i > 0)
      recip = int_recip(i);
    else
      recip = 0;
    return recip;
}



int64 OptLower::uns_recip_shift(int64 tZ) {
    if (tZ == 0) {
	tZ = ~0;
    } else {
	int64 tmp = 64;
	tZ -= 1;
	tZ = bit_left_zeros(tZ);
	tZ = tmp - tZ;
    }
    return tZ;
}

int64 OptLower::int_recip_shift(int64 tZ) {
    if (tZ == 0) {
	tZ = ~0;
    } else {
	int64 tmp = 64;

	if (tZ < 0) {
	    tZ = -tZ;
	}
	tZ -= 1;
	tZ = bit_left_zeros(tZ);
	tZ = tmp - tZ;
    }
    return tZ;
}

 


struct IntF_desc {
       const char * name;
       int string_length;
       boolean is_asm;
       boolean is_intrinsic;
       boolean is_inlineable;
       boolean side_effect_free;
       boolean has_result;
       charP side_effect;
       CT_type_enum templ;
       OpM_type_enum mop;
       int gp_kills;
       int targ_kills;
       charP field_interpretation;
}; 
const int IntF_table_size = 168;




  private:
    static const IntF_desc IntF_table[IntrinsicF::IntF_table_size+1];
  public:
    static IntrinsicId lookup(char const *f);
    static int IntF_desc_compare(char *str, struct IntF_desc *entry);
    static const char * name(IntrinsicId id);
    static boolean parameter_read(IntrinsicId id, unsigned pos);
    static boolean parameter_written(IntrinsicId id, unsigned pos);
    static boolean is_asm(IntrinsicId id);
    static boolean is_intrinsic(IntrinsicId id);
    static boolean is_inlineable(IntrinsicId id);
    static boolean test_variant(IntrinsicId id);
    static boolean has_result(IntrinsicId id);
    static OpM_type_enum mop(IntrinsicId id);
    static CT_type_enum templ(IntrinsicId id);
    static const char *side_effect(IntrinsicId id);
    static boolean side_effect_free(IntrinsicId id);
    static const char *field_interpretation(IntrinsicId id);
    static int gp_kills(IntrinsicId id);
    static int targ_kills(IntrinsicId id);
};

Newsgroups: gnu.g++.bug