After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 516916 - g_assertion_message_cmpnum() uses printf("%Lf")
g_assertion_message_cmpnum() uses printf("%Lf")
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: win32
unspecified
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
Depends on:
Blocks:
 
 
Reported: 2008-02-16 22:52 UTC by Yevgen Muntyan
Modified: 2018-05-24 11:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch (1.31 KB, patch)
2008-11-22 21:05 UTC, Sam Thursfield
none Details | Review
revised patch which is probably a bit better (1.34 KB, patch)
2008-11-22 21:25 UTC, Sam Thursfield
none Details | Review

Description Yevgen Muntyan 2008-02-16 22:52:58 UTC
printf("%Lf") is broken when the code is compiled with mingw compiler, so e.g. g_assert_cmpint() prints "-0" for TRUE.
Comment 1 Sam Thursfield 2008-11-22 21:05:44 UTC
Created attachment 123238 [details] [review]
patch

Here is the obvious patch.
I guess it is possible that really high values will output wrong now, but without this patch all values output wrong so that's quite an improvement.
Comment 2 Sam Thursfield 2008-11-22 21:25:33 UTC
Created attachment 123240 [details] [review]
revised patch which is probably a bit better

I just thought that for int values, the long double can be converted back to gint64 so that all values will work.
Comment 3 Tor Lillqvist 2008-11-23 08:40:02 UTC
I thought there already was a bug open for this, with discussion in general about the functions in question, but couldn't find it. (Maybe this issue was just discussed on IRC when this bug was opened.) I don't remember now what all the issues here were, but I *think* that if you investigate the code surrounding and related to this there will be many more problems on Windows except just what your patch fixes. I might be wrong, though.
Comment 4 Sam Thursfield 2008-11-23 14:24:45 UTC
Thanks for your advice Tor.

Sam@HAJI /c/build/src/glib-2.19.0
$ grep -r "%.*Lf" *
[snip some binary file matches]
glib/gtester.c:  test_log_printfe ("%s<duration>%.6Lf</duration>\n", sindent (lo
g_indent), duration);
glib/gtestutils.c:        /* %Lf is not in msvcrt6's printf function and never w
ill be. */
glib/gtestutils.c:      case 'i':   s = g_strdup_printf ("assertion failed (%s):
 (%.0Lf %s %.0Lf)", expr, arg1, cmp, arg2); break;

It seems the only other place %Lf is used is in gtester - which to my knowledge doesn't even get built on win32 at the moment. 
Comment 5 Sam Thursfield 2008-11-23 14:25:32 UTC
Sorry for the unhelpful line wrapping there
Comment 6 Yevgen Muntyan 2008-11-23 14:40:16 UTC
I think the issue was that glib api takes long double: that's broken when glib is compiled with visual studio and the application is compiled with mingw or vice versa. Also, visual studio long double is 64 bits, so int64 won't fit into it.

Sam's patch does fix a very common case of mingw-compiled glib and application, if it works as advertised.
Comment 7 GNOME Infrastructure Team 2018-05-24 11:19:03 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/124.