The demo:

/******************************/
/* powl_bug.c */
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
 long double sld, ld1, ld2, int1 = 10.0L, int2 = -298.0L;

 sld = strtold("1e-298", NULL);
 printf ("sld : %.21Lg %La\n", sld, sld); /* Correct */

 ld1 = powl(10.0L, -298.0L);
 printf ("ld1 : %.21Lg %La\n", ld1, ld1); /* Correct (constant folding) */

 ld2 = powl(int1, int2);
 printf ("ld2 : %.21Lg %La\n", ld2, ld2); /* Incorrect (math library)   */

 return 0;
}
/******************************/

I build with:
gcc -o powl_bug.exe powl_bug.c -D__USE_MINGW_ANSI_STDIO

powl_bug.exe outputs:
With gcc-13 and gcc-14 (from https://winlibs.com)::
sld : 9.99999999999999999985e-299 0x8.5f0468293f0eb4ep-993
ld1 : 9.99999999999999999985e-299 0x8.5f0468293f0eb4ep-993
ld2 : 1.00000000000000000019e-298 0x8.5f0468293f0eb5p-993

With an old gcc-8.3.0 (not from winlibs):
sld : 9.99999999999999999985e-299 0x8.5f0468293f0eb4ep-993
ld1 : 9.99999999999999999985e-299 0x8.5f0468293f0eb4ep-993
ld2 : 1.00000000000000001211e-298 0x8.5f0468293f0ebc3p-993

This issue was also reported to Debian in late 2013 (and fixed for that
platform in  early 2014). See:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=727841

Do I need to provide any additional information ? (Results seem to be the
same on both 32-bit and 64-bit gcc builds).
To whom should I report this issue ?

Cheers,
Rob

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to