This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Unexpected arithmetic exception


Hi!

Does anybody know whether arithmetic exception is a valid outcome of
the following C program?  That's what I get on mips-sgi-irix{5.2,6.3}
with egcs 1.1.1, for T \in \{ long long, long, int \} and SGI cc for
long and int (it uses __ll_rem for long long).

#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; /* crash here */
}


-- 
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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]