Web lists-archives.com

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

On 07/03/16 01:27, mathog wrote:
> What happens is that a code snippet 
> like this:
>     double val=1.0;
>     printf("%lf\n",val);
> emits 0.0 instead of 1.0.

One might ask what the author of that code hopes to achieve, with printf
format specs such as "%lf".  ISO-C says that the "l" modifier is
redundant (i.e. has no effect) in this context, but Microsoft uses it as
an alias for the "L" modifier.  Frankly, when you use non-standard
constructs, such as this, you really are just asking for trouble.

That said, there is a possible conflict of interests between MinGW's
interpretation of "%Lf", depending on whether the printf() in use is
linked from MSVCRT.DLL, (in which both double and long double are
interpreted as identical 64-bit entities), or the MinGW variant in
libmingwex.a, (in which double is the same as the MSVCRT.DLL version,
but long double is GCC's 80-bit representation).  The choice of which
printf() implementation is linked is determined by feature test macros,
(look in <_mingw.h> to see which), or by use of -ansi or -posix command
line options, when invoking gcc/g++.

> (Within inkscape the bug is much worse, it looks like it is
> formatting random locations in memory, and extremely long strings of
> random digits can be returned.)

This is typical of the behaviour which would be expected, when you push
a GCC 80-bit long double into the argument list, where printf() expects
a 64-bit double, (or a 64-bit double, where MinGW's printf() expects an
80-bit long double, as will always be the case with "%lf", in MinGW's
current printf() implementation; that will change in the next release,
where the ISO-C redundancy effect will be honoured, unless your code
specifically requests otherwise).


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.
MinGW-users mailing list

This list observes the Etiquette found at 
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:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe