GNOME Bugzilla – Bug 764575
tests: Fix compilation errors due to Y2K format problems
Last modified: 2016-10-11 16:19:14 UTC
.
Created attachment 325312 [details] [review] tests: Fix compilation errors due to Y2K format problems Newer versions of GCC are particularly verbose in relation to formatting errors, use GCC pragmas to disable warnings for this section. gdatetime.c: In function ‘test_strftime’: gdatetime.c:1334:3: error: ‘%c’ yields only last 2 digits of year in some locales [-Werror=format-y2k] "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^ gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’ "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gdatetime.c:1334:3: error: ‘%g’ yields only last 2 digits of year [-Werror=format-y2k] "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^ gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’ "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gdatetime.c:1334:3: error: ‘%x’ yields only last 2 digits of year in some locales [-Werror=format-y2k] "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^ gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’ "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gdatetime.c:1334:3: error: ‘%y’ yields only last 2 digits of year [-Werror=format-y2k] "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^ gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’ "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Review of attachment 325312 [details] [review]: In https://git.gnome.org/browse/glib/commit/?id=8cdbc7fb2c8c876902e457abe46ee18a0b134486 we moved the pragma outside of the function to pacify older GCCs, probably do the same here?
Created attachment 325337 [details] [review] tests: Fix compilation errors due to Y2K format problems Newer versions of GCC are particularly verbose in relation to formatting errors, use GCC pragmas to disable warnings for this section. gdatetime.c: In function ‘test_strftime’: gdatetime.c:1334:3: error: ‘%c’ yields only last 2 digits of year in some locales [-Werror=format-y2k] "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^ gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’ "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gdatetime.c:1334:3: error: ‘%g’ yields only last 2 digits of year [-Werror=format-y2k] "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^ gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’ "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gdatetime.c:1334:3: error: ‘%x’ yields only last 2 digits of year in some locales [-Werror=format-y2k] "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^ gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’ "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gdatetime.c:1334:3: error: ‘%y’ yields only last 2 digits of year [-Werror=format-y2k] "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^ gdatetime.c:1334:3: note: in definition of macro ‘TEST_FORMAT’ "a%a A%A b%b B%B c%c C%C d%d e%e F%F g%g G%G h%h H%H I%I j%j m%m M%M " \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Note that the pragma is outside the function as older versions of GCC don't support pragma inside functions.
Attachment 325337 [details] pushed as 35bd692 - tests: Fix compilation errors due to Y2K format problems
Current git master of glib fails to compile for me with gcc-6: gdbus-example-unix-fd-client.c: In function ‘on_name_appeared’: gdbus-example-unix-fd-client.c:85:17: error: ‘%c’ yields only last 2 digits of year in some locales [-Werror=format-y2k] "%c", ^~~~ I can supply a patch, but i'm not sure what is the proper fix? A pragma to disable the warning? Etc?
Created attachment 330902 [details] [review] Gdbus test: fix compilation error due to Y2K format problems
Review of attachment 330902 [details] [review]: This patch is OK, but it seems better to change this to use GDateTime...except do we really not have RFC 3339 formatting there? It looks like g_time_val_to_iso8601() does it... Basically there should be a sane time format that avoids this warning we can use - do you want to look at that?
(In reply to Roman Lebedev from comment #5) > Current git master of glib fails to compile for me with gcc-6: > > gdbus-example-unix-fd-client.c: In function ‘on_name_appeared’: > gdbus-example-unix-fd-client.c:85:17: error: ‘%c’ yields only last 2 digits > of year in some locales [-Werror=format-y2k] > "%c", > ^~~~ > > I can supply a patch, but i'm not sure what is the proper fix? > A pragma to disable the warning? Etc? Can you file a new bug for this?
(In reply to Bastien Nocera from comment #8) > (In reply to Roman Lebedev from comment #5) > > Current git master of glib fails to compile for me with gcc-6: > > > > gdbus-example-unix-fd-client.c: In function ‘on_name_appeared’: > > gdbus-example-unix-fd-client.c:85:17: error: ‘%c’ yields only last 2 digits > > of year in some locales [-Werror=format-y2k] > > "%c", > > ^~~~ > > > > I can supply a patch, but i'm not sure what is the proper fix? > > A pragma to disable the warning? Etc? > > Can you file a new bug for this? Sure, #768453.
y2k has come and gone a lifetime ago... I think this is a gcc bug to elevate this warning to a level where it causes build issues
(In reply to Matthias Clasen from comment #10) > y2k has come and gone a lifetime ago... I think this is a gcc bug to elevate > this warning to a level where it causes build issues Agreed, I bet changing our GLIB_WARN_CFLAGS to have -Wall -Wno-format-y2k would work.
I tested Colin's suggestion: it works and is a much better fix IMHO
pushed to our glib fork a patch if that's of any interest: https://github.com/endlessm/glib/tree/upstream/T13656