I wrote:
I wrote:
If so, it would be helpful if GPC issued a warning in this case, e.g, "result of comparison is always false" (note that GCC does this in some cases, e.g., comparison of unsigned value >= 0).
Good idea. In fact, I made the warnings a bit more extensive (maybe overkill ...), see the test programs. Of course, they still can't catch all cases of unintentionally confusing padding and non-padding comparisons.
Just a little correction to the messages.
I think my previous patch is too noisy. Comparisons of two string constants shouldn't be warned (at least not by default). E.g., in my own code, I sometimes do things like that:
{ Configuration file }
const LogFileName = ''; { optional }
{ Main code }
if LogFileName <> '' then { ... }
This would warn whenever LogFileName is set because of the different lengths of the empty and a nonempty string. I think that's overkill.
So the following patch disables the warning for this case (and does another small internal cleanup).
Frank