This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/10040: Incorrect warning message for bit fields
- From: Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>
- To: <peterson at austin dot ibm dot com>
- Cc: <gcc-gnats at gcc dot gnu dot org>, <gcc-prs at gcc dot gnu dot org>, <gcc-bugs at gcc dot gnu dot org>
- Date: Wed, 12 Mar 2003 17:40:27 +0100 (CET)
- Subject: Re: c/10040: Incorrect warning message for bit fields
On 12 Mar 2003 peterson at austin dot ibm dot 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