public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c/10040: Incorrect warning message for bit fields
@ 2003-03-12 16:45 nathan
  0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2003-03-12 16:45 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, peterson

Synopsis: Incorrect warning message for bit fields

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Wed Mar 12 16:45:28 2003
State-Changed-Why:
    not a bug. A 1 bit int bitfield with -fsigned-bitfields
    cano only represent 0 and -1. Hence the warning.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10040


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c/10040: Incorrect warning message for bit fields
@ 2003-03-12 16:46 Falk Hueffner
  0 siblings, 0 replies; 3+ messages in thread
From: Falk Hueffner @ 2003-03-12 16:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c/10040; it has been noted by GNATS.

From: Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
To: <peterson@austin.ibm.com>
Cc: <gcc-gnats@gcc.gnu.org>, <gcc-prs@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>
Subject: Re: c/10040: Incorrect warning message for bit fields
Date: Wed, 12 Mar 2003 17:40:27 +0100 (CET)

 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
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c/10040: Incorrect warning message for bit fields
@ 2003-03-12 16:26 peterson
  0 siblings, 0 replies; 3+ messages in thread
From: peterson @ 2003-03-12 16:26 UTC (permalink / raw)
  To: gcc-gnats


>Number:         10040
>Category:       c
>Synopsis:       Incorrect warning message for bit fields
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 12 16:26:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     James Peterson, IBM Austin Research Lab
>Release:        3.2.2
>Organization:
>Environment:
RedHat Linux 7.1 on AMD Athlon
>Description:
warning: comparison is always 0 due to width of bit-field

message is generated because a 1 bit field is tested against
one:

    int _v: 1;

    if ((*tlb)._hi._v == 1)

This message comes from around line 3132 in fold-const.c
where a comment says "the constant shifted right by the 
field length should be all zero", and then proceeds to 
create trees for (1 >> (lbitsize-1)) and see if the result
is zero (or all ones).  But lbitsize is 1, so lbitsize-1
is zero and this quantity is then (1 >> 0) which is still
1, and hence non-zero (but is all one's to the size of the
bit field, so maybe the problem is integer_all_onesp).

This code is followed by explicit code dealing with 
"single-bit compares".

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"

>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-03-12 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-12 16:45 c/10040: Incorrect warning message for bit fields nathan
  -- strict thread matches above, loose matches on Subject: below --
2003-03-12 16:46 Falk Hueffner
2003-03-12 16:26 peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).