Okay, I have found out that the described behaviour has nothing to do with the 
gcc version. It only depends on the mingw-w64 version.

With mingw-w64 v7 I get the following:
- Linking neither CRT_fp8.0 nor CRT_fp10.o : inconsistent behaviour
- Linking CRT_fp8.o: consistent behaviour
- Linking CRT_fp10.o: inconsistent behaviour

With mingw-w64 v8 I get the following:
- Linking neither CRT_fp8.0 nor CRT_fp10.o : consistent behaviour
- Linking CRT_fp8.o: inconsistent behaviour
- Linking CRT_fp10.o: consistent behaviour

Result: Version 8 behaves exactly the other way round compared to Version 7. Is 
this okay? File float.h at line 272 documents the version 7 behaviour, doesn't 
it?

Exchanging files libwinpthread-1.dll between v7 and v8 again flips the 
behaviour. This surprises me, since linking CRT_fp*.o should hardcode my 
settings in the .exe file, shouldn't it? So if shipping the software with 
another dll leads to inversed behaviour, this is bad.

Where is the bug? Is there an error with mingw-builds? Am I doing something 
wrong? Or is there a bug in mingw-w64?

I am excited about your answer. Thank you very much for your help up to now.

Benjamin

-----Ursprüngliche Nachricht-----
Von: Carl Kleffner [mailto:[email protected]] 
Gesendet: Donnerstag, 6. Mai 2021 14:38
An: [email protected]
Betreff: Re: [Mingw-w64-public] Setting Floating-Point Operation Precision 
Changes With Gcc 10.3

You can set the FPU precision for the main thread by linking CRT_fp8.o or 
CRT_f10.o. Extended precision is the default for most mingw-w64 based 
toolchains as the math library used in mingw-w64 is based on this. The question 
is: what happens when a new thread is started?.

Answer: Windows starts new threads NEVER with extended precision, because 
double precision is the default for MS VS Studio and the Win32 API.

To get consistent behaviour inside a mingw-w64 based project the FPU precision 
must be coded consistently by the programmer itself. Or you have to use the 
patch https://sourceforge.net/p/mingw-w64/mingw-w64/ci/295fafc :
consistent behaviour will be guaranteed automatically at least for pthreads. I 
guess this patch is not included in the v8 of mingw-w64.

If you are not sure what is happening use:
https://github.com/jevinskie/fpudump to print out the FPU state anywhere in 
your program. It may only work with C, but not with C++ programs, but I'm not 
sure.

Am Do., 6. Mai 2021 um 10:11 Uhr schrieb Benjamin Bihler <
[email protected]>:

> It may have to do something with the commit you have mentioned. I am 
> not sure... I am a compiler end user, not a compiler developer. What 
> does that mean? That linking CRT_fp8 or CRT_fp10 is not the right way 
> anymore to set
> x87 precision?
>
> Benjamin
>
> -----Ursprüngliche Nachricht-----
> Von: Liu Hao [mailto:[email protected]]
> Gesendet: Dienstag, 4. Mai 2021 16:56
> An: [email protected]; Carl Kleffner < 
> [email protected]>
> Betreff: Re: [Mingw-w64-public] Setting Floating-Point Operation 
> Precision Changes With Gcc 10.3
>
> 在 2021-05-04 22:46, Carl Kleffner 写道:
> > I can't reproduce this behaviour. With gcc-10.3 on msys2/ucrt64 as 
> > well
> as
> > msy2/mingw64 I get consistent results, regardless if I link 
> > CRT_fp10.o, CRT_fp8.o or none of them.
> >
> >
>
> Does it have something to do with
> https://sourceforge.net/p/mingw-w64/mingw-w64/ci/295fafc?
>
>
> --
> Best regards,
> Liu Hao
>
>
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to