gnu/185622: Obsolete bundled gcc gives ICE

Torbjörn Granlund tg at gmplib.org
Thu Jan 9 23:00:01 UTC 2014


>Number:         185622
>Category:       gnu
>Synopsis:       Obsolete bundled gcc gives ICE
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 09 23:00:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Torbjörn Granlund
>Release:        9.2-RELEASE
>Organization:
KTH
>Environment:
FreeBSD tutufbsd32v92.gmplib.org 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898: Fri Sep 27 03:52:52 UTC 2013     root at bake.isc.freebsd.org:/usr/obj/usr/src/sys/GENERIC  i386

>Description:
Plain compile using bundled gcc gives ICE.
>How-To-Repeat:
The compile command,

$ gcc -m32 -O2 -march=amdfam10 foo.c

results in,

/home/tege/foo.c: In function 'mpn_rootrem_internal':
/home/tege/foo.c:71: internal compiler error: in memory_address_length, at config/i386/i386.c:13897
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions

instead of an object file.

This is your bug, not GNU's, since you insist on using a historic gcc.
>Fix:


Patch attached with submission follows:

typedef unsigned int size_t;
typedef unsigned long int mp_limb_t;
typedef unsigned long int mp_bitcnt_t;
typedef mp_limb_t * mp_ptr;
typedef const mp_limb_t * mp_srcptr;
typedef long int mp_size_t;

struct tmp_reentrant_t {
  struct tmp_reentrant_t *next;
  size_t size;
};
void *__gmp_tmp_reentrant_alloc (struct tmp_reentrant_t **, size_t) __attribute__ ((malloc));

static mp_size_t mpn_rootrem_internal (mp_ptr, mp_ptr, mp_srcptr, mp_size_t,
           mp_limb_t, int);

int foo ();

mp_size_t
__gmpn_rootrem (mp_ptr rootp, mp_ptr remp,
      mp_srcptr up, mp_size_t un, mp_limb_t k)
{
  return mpn_rootrem_internal (rootp, remp, up, un, k, 0);
}

static mp_size_t
mpn_rootrem_internal (mp_ptr rootp, mp_ptr remp, mp_srcptr up, mp_size_t un,
        mp_limb_t k, int approx)
{
  mp_ptr rp, sp;
  mp_size_t rn, sn, nl;
  mp_limb_t cy;
  unsigned long int unb;
  unsigned long int xnb;
  unsigned long kk;
  int ni, i;
  struct tmp_reentrant_t *__tmp_marker;

  __tmp_marker = 0;

  rp = ((mp_limb_t *) (__builtin_expect ((((un + 1) * sizeof (mp_limb_t)) < 65536) != 0, 1) ? __builtin_alloca((un + 1) * sizeof (mp_limb_t)) : __gmp_tmp_reentrant_alloc (&__tmp_marker, (un + 1) * sizeof (mp_limb_t))));

  sp = rootp;

  int __cnt;
  mp_bitcnt_t __totbits;
  __cnt = __builtin_clzl ((up)[(un)-1]);
  __totbits = (mp_bitcnt_t) (un) * 32 - (__cnt);
  (unb) = (__totbits + (1)-1) / (1);

  xnb = (unb - 1) / k + 1;

  if (xnb == 1)
    {
      rootp[0] = 1;
      return un;
    }

  if ((kk % 32) != 0)
    cy = foo (rp, up + kk / 32, rn, kk % 32);
  else
    cy = 0;

  for (i = ni; i != 0; i--)
    {
      if ((kk % 32) != 0)
	cy = foo (rp, up + kk / 32, nl, kk % 32);
      else
	cy = 0;
    }
}


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list