This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Unexpected arithmetic exception
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: Unexpected arithmetic exception
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 08 Feb 1999 16:15:07 -0200
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