It is a real incompatibility between VC and mingw. Visual C++ dropped
support for 80 bit long doubles on x87 many years ago, in VC long doubles
are 64 bit, which is why they use 0x27F. mingw still supports 80 long
doubles on x87. As long this is the case, it is incosistent for mingw to
set computation accuracy to 0x27f.

The 'long double' size incompatibility requires mingw to implement various
long-double functions including printf and scanf, independently of MSVCRT.

So the decision is whether long doubles should be 64 or 80 bits. The
control word is simply the result of this decision.

BTW. see Kahan about long doubles (in Java, though),
http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf


2014-11-23 18:03 GMT+02:00 Carl Kleffner <cmkleff...@gmail.com>:

> What I'm talking about ist the following:
>
> CRT_fp10.o on startup executes FNINIT. According to
> http://www.intel.com/Assets/ja_JP/PDF/manual/253665.pdf:
>
> "When the x87 FPU is initialized with either an FINIT/FNINIT or
> FSAVE/FNSAVE instruction, the x87 FPU control word is set to 037FH, which
> masks all floating-point exceptions, sets rounding to nearest, and sets the
> x87 FPU precision to 64 bits."
>
> That is 80-bit double extended computation precision as default and
> definitly not the expected double computation precision. See also:
>
> http://sourceforge.net/p/mingw/bugs/904/
> https://ghc.haskell.org/trac/ghc/ticket/7289
>
> Carl
>
>
> 2014-11-23 10:52 GMT+01:00 Yaron Keren <yaron.ke...@gmail.com>:
>
>> http://msdn.microsoft.com/en-us/library/e9b52ceh.aspx
>>
>> I think three issues are conflated:
>>
>> 1 long double size is 80 bits in mingw and 64 bits in VC.
>>
>> 2 The mask 0x27F will set the 80-bit extended computation precision,
>> _PC_64 (64/80) and not _PC_53 (53/64) computation precision. This is
>> internal FPU computation precision regardless the external representation
>> size.
>>
>> 3 The exceptions Carl refers are disabled by setting the _MCW_EM mask,
>> mostly 0x1F of the 0x27F mentioned. This is independent the computation
>> precision or long double size.
>>
>> see also
>> http://www.exploringbinary.com/when-doubles-dont-behave-like-doubles/
>>
>>
>>
>> 2014-11-23 11:08 GMT+02:00 Kai Tietz <ktiet...@googlemail.com>:
>>
>>> 2014-11-23 9:17 GMT+01:00 Ozkan Sezer <seze...@gmail.com>:
>>> > On 11/12/14, Carl Kleffner <cmkleff...@gmail.com> wrote:
>>> >> Hi,
>>> >>
>>> >> during tests with my mingw builds variant mingw-w64-for-python
>>> >> <https://bitbucket.org/carlkl/mingw-w64-for-python/downloads> I
>>> stumpled
>>> >> upon a flaw in mingw-w64 FPU handling on startup. This is issued at
>>> >> mingw-w64 builds of numpy <https://github.com/numpy/numpy/issues/5194>
>>> and
>>> >> test
>>> >> failures when building win32 binaries with mingw based on gcc 4.8
>>> >> <https://github.com/numpy/numpy/issues/4909>. The reason for this
>>> >> behaviour: CRT_fp10.o (part of libmingw32.a) sets the FPU control
>>> word to
>>> >> extended precision on startup as per default. This can be overwritten
>>> by
>>> >> additionally linking CRT_fp8.o, but this is documented elsewhere
>>> >> (floath.h). As far I can see, this behaviour in mingw-w64 inherits
>>> from the
>>> >> Mingw32 codebase, but I'm not sure.
>>> >>
>>> >> There seems to be a consense, that 027f should be the standard for
>>> setting
>>> >> the FPU control word. Otherwise it gets into your way, see i.e.
>>> Random and
>>> >> unexpected EXCEPTION_FLT_DIVIDE_BY_ZERO and
>>> >> EXCEPTION_FLT_INVALID__OPERATION
>>> >> <
>>> http://blogs.msdn.com/b/dougste/archive/2008/11/12/random-and-unexpected-exception-flt-divide-by-zero-and-exception-flt-invalid-operation.aspx
>>> >
>>> >>
>>> >> Is there some code in mingw.w64 that depends on extended precision as
>>> a
>>> >> default value? Otherwise this should be fixed in the mingw-w64
>>> codebase
>>> >> IMHO.
>>> >>
>>> >> Regards
>>> >>
>>> >> Carl
>>> >
>>> > PING ?
>>> >
>>> > --
>>> > O.S.
>>>
>>> Well, there is AFAIK.  We have the 'long double' support, which is
>>> actually using 80-bit extended-mode x87 FPU,
>>>
>>> So, not sure if need to keep it for this.
>>>
>>> Kai
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>>> Get technology previously reserved for billion-dollar corporations, FREE
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Mingw-w64-public mailing list
>>> Mingw-w64-public@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
>> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
>> with Interactivity, Sharing, Native Excel Exports, App Integration & more
>> Get technology previously reserved for billion-dollar corporations, FREE
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Mingw-w64-public mailing list
>> Mingw-w64-public@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>>
>>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
>
> http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
> _______________________________________________
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to