SH gcc 2.95.2 _divdi3 miscompiled
Schirmer, Hartmut
HSchirmer@Innovative-Systems.de
Wed Jun 26 13:18:00 GMT 2002
Hi,
Compiler: gcc 2.95.2 cygwin -> sh-hitachi-coff cross
The generated m2/libgcc2.a (big endian) is broken,
__divdi3 is miscompiled. The following function
long long foo(void)
{
long long x, y;
x = -1296760832;
y = -39829;
return x / y;
}
returns 0 instead of the correct value.
Replacing __divdi3.o in libgcc.a with
typedef int word_type __attribute__ ((mode (__word__)));
typedef int DItype __attribute__ ((mode (DI)));
typedef unsigned int UDItype __attribute__ ((mode (DI)));
DItype
__divdi3 (DItype u, DItype v)
{
word_type c = 0;
DItype w;
if (u < 0)
c = ~c, u = -u;
if (v < 0)
c = ~c, v = -v;
w = (UDItype)u / (UDItype)v;
if (c)
w = -w;
return w;
}
fixes the problem
Hartmut
More information about the Gcc-bugs
mailing list