c/3190: Re: gcc bug: complaint on %c for strftime

Pavel Roskin proski@gnu.org
Tue Nov 26 15:50:00 GMT 2002


> (b) I'll predict now that if GCC and C-based languages with strftime are
> still in use in the 2090s,

Agreed

> people then will be cursing anyone who now removes Y2K (and Y2.1K)
> warnings for -Wall, assisting in proliferation of bad code, unless by
> then there have been major improvements through other methods in the
> ability to write correct code.

Such methods do exist (windowing), and they are used already.

I agree that unconditional stripping most significant part of the year in
the format is wrong and should be discouraged.

On the other hand, I don't want to be warned about doing the right thing
and using the user-preferred format when giving information to the end
users, just because people in some country use two-digit years (e.g. the
age of their emperor).  It's not my problem.  It may (or may not) be a
problem of that country.

> (c) A simple conservative change would be to move -Wformat-y2k out of
> -Wformat (into -Wformat=2 alongside -Wformat-nonliteral and
> -Wformat-security; -Wformat-security being another option I think would
> fit the definition of -Wall).  But see (b) about people in 90 years' time
> cursing such a change.

I have no problem with warnings about modifiers like %y and %D, even as
part of -Wall.

On the other hand, I believe that the warning about %c (as well as %x and
some other locale-specific formats) is invalid and should be eliminated
completely.  %c uses locale-specific format by definition.  If that's
considered a problem, let's also warn that the months can be printed in a
foreign language, or that the day can be printed before the month.

Date formatted by %c is not meant to be parsed back to the machine
readable form.  Pretending that it is could encourage bad programming.

-- 
Regards,
Pavel Roskin



More information about the Gcc mailing list