ModuloTest fails on mips

Date view Thread view Subject view Author view

From: Alexandre Oliva (oliva@dcc.unicamp.br)
Date: Mon Feb 08 1999 - 13:17:45 EST


0x8...0 % 0xf...f generates an arithmetic exception on mips. The
following programs demonstrates this.

Should we test for this failure at configure time and generate extra
code to expand `a%b' to `(b==-1)?0:(a%b)' ? :-(

#ifndef T
#define T long long
/* #define T long */
/* #define T int */
#endif

typedef T t;
typedef unsigned T ut;

t foo(t i, t j);
int main() {
  t i = 0, j = -1;
  i = ((ut)(~i)>>1)+1; /* 0x80...0 */
  if (foo(i, j))
    abort();
  return 0;
}

t foo(t i, t j) {
  return i % j;
}

-- 
Alexandre Oliva  http://www.dcc.unicamp.br/~oliva  aoliva@{acm.org}
oliva@{dcc.unicamp.br,gnu.org,egcs.cygnus.com,samba.org}
Universidade Estadual de Campinas, SP, Brasil


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Sep 23 2000 - 19:58:01 EDT