https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128156
Bug ID: 128156
Summary: libgcc: long _Accum division LACCUM_MIN / LACCUM_MIN
returns -1.0 instead of 1.0
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgcc
Assignee: unassigned at gcc dot gnu.org
Reporter: yuki.tanaka at defaultcase dot de
Target Milestone: ---
typedef long _Accum T;
__attribute__((noipa)) T a(T x, T y)
{
return x / y;
}
int main(void)
{
if (a(__LACCUM_MIN__, __LACCUM_MIN__) != 1.0lk)
__builtin_abort();
return 0;
}
$ arm-none-eabi-gcc -O2 -march=armv7-a -mthumb --specs=rdimon.specs
-Wl,-Ttext-segment=0x400000 lkdiv.c -o lkdiv
$ qemu-arm ./lkdiv; echo $?
1
Any nonzero value divided by itself is 1.0, and 1.0 is representable in long
_Accum. Instead a returns -1.0 and main aborts.
Compiler Explorer:
https://godbolt.org/z/bYz9dK6jn
GCC 17:
a:
push {r3, lr}
bl __gnu_divda3
pop {r3, pc}