c/3190: -Wformat-y2k doesn't belong to -Wall - it's hard to avoid

proski@gnu.org proski@gnu.org
Thu Jun 14 22:56:00 GMT 2001


>Number:         3190
>Category:       c
>Synopsis:       -Wformat-y2k doesn't belong to -Wall - it's hard to avoid
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 14 22:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     proski@gnu.org
>Release:        gcc-3_0-branch CVS
>Organization:
>Environment:
RedHat Linux 7.1, i586 (K6-2)
>Description:
-Wall assumes -Wformat which in turn includes -Wformat-y2k

invoke.texi says:
-Wall ... enables all the warnings ... that are easy to avoid (or modify to prevent the warning)

The warning is:
`%c' yields only last 2 digits of year in some locales

No method is suggested to avoid the warning. I really want to use what the user prefers by setting locale. It's a user visible string.

I fail to see how this is "easy to avoid" without sacrificing some functionality.
>How-To-Repeat:
$ cat >test.c <<EOF
int main()
{
    strftime (NULL, 0, "%c", NULL);
    return 0;
}
EOF
$ gcc -c -Wall test.c
===> test.c:4: warning: `%c' yields only last 2 digits of year in some locales
>Fix:
(Very incomplete!!! Documentation should be changed in several places)
--- c-format.c
+++ c-format.c
@@ -59,12 +59,12 @@ set_Wformat (setting)
      int setting;
 {
   warn_format = setting;
-  warn_format_y2k = setting;
   warn_format_extra_args = setting;
   if (setting != 1)
     {
       warn_format_nonliteral = setting;
       warn_format_security = setting;
+      warn_format_y2k = setting;
     }
 }
 
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list