Web lists-archives.com

Re: [Mingw-users] bizarre problem, need help from a mingw developer




On 09/03/16 20:03, mathog wrote:
>> (My own
>> > preference is to use a gcc option, such as -ansi or -posix, or any of
>> > the -std= options which implies __STRICT_ANSI__
> You mean like: -std=c99  ???
> 
> That does not work, at least on the mingw I have installed.  With NO
> flags one gets the C99 behavior:
> 
>> > gcc -o printf_bug printf_bug.c
>> > printf_bug
> val 1.000000
> esc 0.000000 cos 1.000000 sin 0.000000 -sin 0.000000 -cos -1.000000
> esc 0.000000 cos 1.000000 sin 0.000000 -sin 0.000000 -cos -1.000000

No.  You get the MSVCRT.DLL printf() behaviour, which is NOT the same as
C99 behaviour; it just happens that your test case is inadequate to
discriminate, because MSVC doesn't provide a distinct implementation of
long doubles, (their so-called long doubles are 64-bit, and identically
equivalent to their 64-bit doubles), whereas in GCC, a long double is
80-bits, while double is 64-bits, (identical to MSVC's double).

The bottom line is that MSDN says that "%lf" refers to a long double,
and __mingw_printf() interprets that to mean a GCC long double.  You are
being fooled into believing that your test case reveals the C99
behaviour in MSVCRT.DLL's printf(), simply because MSVCRT.DLL cannot
process GCC long doubles (at all), and the specified reference to a long
double argument is (fortuitously, maybe) satisfied by passing a double,
not because it is correct, but because the correct and the incorrect are
indistinguishable [*] within MSVCRT.DLL.

[*] It's precisely because of this lack of distinction, that I now
believe that the next release of mingwrt should ignore this Microsoft
anomalous use of "%lf" formatting, and defer instead to C99 behaviour;
(which is, in no way, to be construed as any implied change in my
opinion, that code which specifies "%lf" formatting is anything less
that utterly broken in the first place).

-- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe