GNOME Bugzilla – Bug 516916
g_assertion_message_cmpnum() uses printf("%Lf")
Last modified: 2018-05-24 11:19:03 UTC
printf("%Lf") is broken when the code is compiled with mingw compiler, so e.g. g_assert_cmpint() prints "-0" for TRUE.
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.
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.
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.
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.
Sorry for the unhelpful line wrapping there
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.
-- 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.