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 764575 - tests: Fix compilation errors due to Y2K format problems
tests: Fix compilation errors due to Y2K format problems
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-04-04 09:14 UTC by Bastien Nocera
Modified: 2016-10-11 16:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tests: Fix compilation errors due to Y2K format problems (2.77 KB, patch)
2016-04-04 09:14 UTC, Bastien Nocera
none Details | Review
tests: Fix compilation errors due to Y2K format problems (2.72 KB, patch)
2016-04-04 13:09 UTC, Bastien Nocera
committed Details | Review
Gdbus test: fix compilation error due to Y2K format problems (1.02 KB, patch)
2016-07-05 12:38 UTC, Roman Lebedev
reviewed Details | Review

Description Bastien Nocera 2016-04-04 09:14:53 UTC
.
Comment 1 Bastien Nocera 2016-04-04 09:14:57 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 " \
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comment 2 Colin Walters 2016-04-04 12:55:03 UTC
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?
Comment 3 Bastien Nocera 2016-04-04 13:09:11 UTC
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.
Comment 4 Bastien Nocera 2016-04-04 13:10:53 UTC
Attachment 325337 [details] pushed as 35bd692 - tests: Fix compilation errors due to Y2K format problems
Comment 5 Roman Lebedev 2016-07-05 12:35:08 UTC
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?
Comment 6 Roman Lebedev 2016-07-05 12:38:51 UTC
Created attachment 330902 [details] [review]
Gdbus test: fix compilation error due to Y2K format problems
Comment 7 Colin Walters 2016-07-05 15:47:34 UTC
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?
Comment 8 Bastien Nocera 2016-07-05 16:04:23 UTC
(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?
Comment 9 Roman Lebedev 2016-07-05 16:32:55 UTC
(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.
Comment 10 Matthias Clasen 2016-07-05 16:34:19 UTC
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
Comment 11 Colin Walters 2016-07-05 17:20:51 UTC
(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.
Comment 12 xaiki 2016-10-06 19:59:15 UTC
I tested Colin's suggestion: it works and is a much better fix IMHO
Comment 13 xaiki 2016-10-11 16:19:14 UTC
pushed to our glib fork a patch if that's of any interest:
https://github.com/endlessm/glib/tree/upstream/T13656