This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: warning: `%y' yields only last 2 digits of year


<<Well, I think, warnings should be ultimately usefull for most users.
E.g.  those other warnings about printf() formats I think are usefull.
They would need to go away when the above principle is applied, because
it's an application of the language, not a language mean itself (i.e.
'debug("%s:%d", 42);' is prefectly legal C, but gcc can warn about this).
I'm not sure if you think this is useless.
>>

No, that's compeltely different, and I am a little amazed that you do
not see the difference. Warnings are of *course* about legal C. If the
C were not legal, there would be an error message and no need for a 
warning. Warnings are appropriate when someone writes code that is

a) definitely or likely undefined according to the C standard
b) likely to do something different than intended according to our
    understanding of the way the language is used.

<<So, what you are trying to tell us in your priggish style is, that we
shouldn't warn about any perfectly well defined thing?  (Usefullness can't
be measured exactly and differs between users, so shouldn't be a
criterion)  Because it's reasonable to assume, that every users knows what
it does?  A strange opinion IMHO.
>>

How can a user *not* know that %y generates only the low two order digits
of the year, I just don't see any scenario under which that is true, since
the output is obvious. That's even *more* clear when someone writes 19%y,
in this case it is 100% clear that the user knows what it does, and it is
a bit amazing to me that you would claim otherwise.

The warning in this case is about code that

 a) is legal and well defined
 b) most certainly does exactly what the user intended when the code
	was written

The justification of the warning is that we guess that the code may no
longer do what is intended, because of Y2K considerations. 

Now, even if that is valid, I think it is a useless warning. Why? Because
solving Y2K problems requires addressing many problems on many fronts. 
Certainly searching for %y is a trivial part of the total effort, and I
cannot believe that it is a significant help.

> About the usefullness of this %y warning: I'm not sure of it.

Well the entire debate is about the usefulness of this warning, so you 
are really saying you are not sure what side to take :-)

> I guess as it was introduced and used for recompiling old sources
> some potentially problematic uses of %y were discovered, where
> the original author did not meant to use it.
> This alone would have justified the warning.

Again, I can't see it being used where it was not intended, I think what
you mean is something like "the author did not anticipate the Y2K problem".

First, it would be nice to have some testimony that confirmed this, rather
than rely on guesses.

Second, the fact that a warning is helpful in one case is NOT at ALL a
justification for the warning. The problem with warnings is carefully
balancing useful warnings against false positives. If -Wall contains
too many junk warnings that generate too many false positives, then
people react by turning off -Wall completely and there is a real loss.

> If it should be in -Wall I don't know.

But that is what the discussion is all about, and again you are saying
you don't know what position to take. I have no objection to having
some special warning flag that no one will use :-)

My viewpoint (sorry if it appears "priggish") is that -Wall should not
include warnings of the kind that unconditionally warn about all
possible uses of a feature, essentially declaring the feature to be
a bad idea that should not be present. This seems like a case of the
compiler writer saying "I know better than the language and library
designers", and I don't think compiler writers should be in that
business.

> If yes, your insurance company surely
> will find out how to switch off the warning and can audit the code by
> hand.

Yes, and if that happens too often, that's unfortunate, and if it is the
case that this %y warning causes this to happen, then that's an argument
for excluding this from -Wall.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]