c/10040: Incorrect warning message for bit fields
Falk Hueffner
falk.hueffner@student.uni-tuebingen.de
Wed Mar 12 17:15:00 GMT 2003
On 12 Mar 2003 peterson@austin.ibm.com wrote:
> int _v: 1;
> if ((*tlb)._hi._v == 1)
>
> warning: comparison is always 0 due to width of bit-field
The warning seems 100% correct to me. The comparison *is* always 0.
> In trying to explain the problem, I'm beginning to see that this error
> message is a result of the bit field being an "int" (signed) rather
> than "unsigned int". In which case, maybe the problem is best
> addressed by a different warning message -- "bit field too small for
> value and sign bit; consider unsigned type for field"
That's too much guessing for my taste. The declaration might be just what
was intended, and only the comparison is bogus. At most I'd consider
"warning: comparison is always 0 due to width and signedness of
bit-field".
Falk
More information about the Gcc-bugs
mailing list