在 2020/8/13 下午2:56, Takashi Inoue 写道: > Hi All, > > I made C version of sample code which demonstrate the problem(?). > I attach the code to this post. > I renamed files so that ML system does not remove files. > So, please rename back "cdemo.txt" to "cdemo.c" and > "Makefile.txt" to "Makefile." I'm sorry for this. > > With these two files, make produce cdemo.exe. > If you run cdemo.exe several times, I think, > you will get different "out.txt" at time to time, as I did. > > I see this behavior with mingw-w64 of x86-64 package of msys2. > I'm not sure whether this happens with other setup of mingw-w64. > So, I'm very grateful if you check behavior on your system and let me know, > especially if you have some other set up of mingw-w64. > >
Thanks for this report. I believe this issue is caused by the x87 precision
setting.
I inserted a call to this function right before your `pow()`:
void tell_precision(void)
{
const char* s;
switch(_controlfp(0, 0) & _MCW_PC) {
case _PC_24:
s = "SINGLE";
break;
case _PC_53:
s = "DOUBLE";
break;
case _PC_64:
s = "EXTENDED";
break;
default:
s = "<unknown>";
break;
}
printf("thread %u, precision %s\n", GetCurrentThreadId(), s);
}
and I got this output:
thread 6264, precision DOUBLE
thread 6264, precision DOUBLE
thread 6264, precision DOUBLE
thread 6264, precision DOUBLE
thread 6264, precision DOUBLE
thread 6264, precision DOUBLE
thread 8792, precision EXTENDED
thread 8792, precision EXTENDED
thread 8792, precision EXTENDED
thread 8792, precision EXTENDED
thread 3928, precision DOUBLE
thread 3928, precision DOUBLE
thread 3928, precision DOUBLE
thread 3928, precision DOUBLE
thread 3928, precision DOUBLE
thread 6264, precision DOUBLE
thread 6264, precision DOUBLE
thread 5160, precision DOUBLE
thread 5160, precision DOUBLE
thread 5160, precision DOUBLE
thread 8792, precision EXTENDED
Our `pow()` implementation calls `exp2l()` and `log2l()` without setting 64-bit
precision accordingly. Right now I have had
a idea in mind but don't have time to compose a patch. I will do that later
today (~7hrs later).
--
Best regards,
LH_Mouse
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
