public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses
@ 2003-10-15 18:07 nomura at netapp dot com
  2003-10-15 18:09 ` [Bug c/12625] " nomura at netapp dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: nomura at netapp dot com @ 2003-10-15 18:07 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625

           Summary: bitfields of size 8 missed by -Wparentheses
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nomura at netapp dot com
                CC: gcc-bugs at gcc dot gnu dot org

This testcase:

[siml4]$ cat bug.c

struct { int i:8; } s; 

void foo()
{
        if (s.i = 0) ;
}

is compiled as follows:

[siml4]$ tools/i686-gcc -c -Wparentheses bug.c

and we expect that -Wparentheses should warn as follows:

bug.c: In function `foo':
bug.c:5: warning: suggest parentheses around assignment used as truth value

but no warning is issued.  This thwarts our use of -Wparentheses to
clean up our code.  Moreover it's inconsistent in that any other 
declaration of field "i" seems to result in a warning.  
Bitfield of size 7 or 9 gives a warning.
short instead of int gives a warning.  
Non bitfields give a warning.

Seen in 3.3.1 on Linux (see below), but also in the 3.2 compiler packaged
with Redhat Linux 8 -- so it's probably not too sensitive to version.

[siml4]$ tools/i686-gcc -v
Reading specs from
/usr/local/build/compilers/gcc-3.3.1_277537/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/specs
Configured with: ../gcc-3.3.1/configure
--enable-languages=c,c++,f77,java,objc,treelang
--prefix=/usr/local/build/compilers/gcc-3.3.1_277537
Thread model: posix
gcc version 3.3.1 ($Change: 277537 $)
[siml4]$


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

* [Bug c/12625] bitfields of size 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
@ 2003-10-15 18:09 ` nomura at netapp dot com
  2003-10-15 18:16 ` nomura at netapp dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nomura at netapp dot com @ 2003-10-15 18:09 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


nomura at netapp dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   GCC host triplet|                            |Linux Redhat 8
 GCC target triplet|                            |i686-pc-linux-gnu


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

* [Bug c/12625] bitfields of size 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
  2003-10-15 18:09 ` [Bug c/12625] " nomura at netapp dot com
@ 2003-10-15 18:16 ` nomura at netapp dot com
  2003-10-15 18:17 ` [Bug c/12625] bitfields which have sizes that are powers of " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: nomura at netapp dot com @ 2003-10-15 18:16 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


nomura at netapp dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   GCC host triplet|Linux Redhat 8              |i686-pc-linux-gnu


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

* [Bug c/12625] bitfields which have sizes that are powers of 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
  2003-10-15 18:09 ` [Bug c/12625] " nomura at netapp dot com
  2003-10-15 18:16 ` nomura at netapp dot com
@ 2003-10-15 18:17 ` pinskia at gcc dot gnu dot org
  2004-01-19 19:29 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-15 18:17 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   GCC host triplet|i686-pc-linux-gnu           |
 GCC target triplet|i686-pc-linux-gnu           |
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2003-10-15 18:17:19
               date|                            |
            Summary|bitfields of size 8 missed  |bitfields which have sizes
                   |by -Wparentheses            |that are powers of 8 missed
                   |                            |by -Wparentheses


------- Additional Comments From pinskia at gcc dot gnu dot org  2003-10-15 18:17 -------
I can confirm this. Also it is not just size 8 that does it as 16 (and 32 on a long long) does it.


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

* [Bug c/12625] bitfields which have sizes that are powers of 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
                   ` (2 preceding siblings ...)
  2003-10-15 18:17 ` [Bug c/12625] bitfields which have sizes that are powers of " pinskia at gcc dot gnu dot org
@ 2004-01-19 19:29 ` pinskia at gcc dot gnu dot org
  2004-07-20 14:51 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-19 19:29 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


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

* [Bug c/12625] bitfields which have sizes that are powers of 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
                   ` (3 preceding siblings ...)
  2004-01-19 19:29 ` pinskia at gcc dot gnu dot org
@ 2004-07-20 14:51 ` pinskia at gcc dot gnu dot org
  2004-07-20 14:59 ` jsm at polyomino dot org dot uk
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-20 14:51 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-07-20 14:51 -------
Fixed for 3.5.0 by the bitfield patch for C.
: Search converges between 2004-07-08-trunk (#482) and 2004-07-09-trunk (#483).



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |3.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


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

* [Bug c/12625] bitfields which have sizes that are powers of 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
                   ` (4 preceding siblings ...)
  2004-07-20 14:51 ` pinskia at gcc dot gnu dot org
@ 2004-07-20 14:59 ` jsm at polyomino dot org dot uk
  2004-07-20 15:15 ` [Bug c++/12625] " giovannibajo at libero dot it
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jsm at polyomino dot org dot uk @ 2004-07-20 14:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jsm at polyomino dot org dot uk  2004-07-20 14:59 -------
Subject: Re:  bitfields which have sizes that are powers of 8
 missed by -Wparentheses

On Tue, 20 Jul 2004, pinskia at gcc dot gnu dot org wrote:

> Fixed for 3.5.0 by the bitfield patch for C.

I've committed the following testcase for this bug as none was included
with the bit-field patch.  Note however that the bug still exists for C++.

Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/ChangeLog,v
retrieving revision 1.4022
diff -u -r1.4022 ChangeLog
--- ChangeLog	20 Jul 2004 09:57:09 -0000	1.4022
+++ ChangeLog	20 Jul 2004 14:57:27 -0000
@@ -1,3 +1,7 @@
+2004-07-20  Joseph S. Myers  <jsm@polyomino.org.uk>
+
+	* gcc.dg/pr12625-1.c: New test.
+
 2004-07-20  Steven Bosscher  <stevenb@suse.de>
 
 	* testsuite/gcc.dg/switch-warn-1.c: New test.
Index: gcc.dg/pr12625-1.c
===================================================================
RCS file: gcc.dg/pr12625-1.c
diff -N gcc.dg/pr12625-1.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc.dg/pr12625-1.c	20 Jul 2004 14:57:27 -0000
@@ -0,0 +1,13 @@
+/* Warning for assignment used as truth-value should apply for
+   bit-fields.  */
+/* Origin: bug 12625 from nomura at netapp.com */
+/* { dg-do compile } */
+/* { dg-options "-Wparentheses" } */
+
+static struct { int i:8; } s; 
+
+void
+foo ()
+{
+  if (s.i = 0) ; /* { dg-warning "parentheses" "warning for bit-field" } */
+}



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


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

* [Bug c++/12625] bitfields which have sizes that are powers of 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
                   ` (5 preceding siblings ...)
  2004-07-20 14:59 ` jsm at polyomino dot org dot uk
@ 2004-07-20 15:15 ` giovannibajo at libero dot it
  2004-07-22  3:22 ` pinskia at gcc dot gnu dot org
  2004-10-13 12:35 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-07-20 15:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-07-20 15:15 -------
Then, reopening this as a C++ bug.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
          Component|c                           |c++
         Resolution|FIXED                       |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


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

* [Bug c++/12625] bitfields which have sizes that are powers of 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
                   ` (6 preceding siblings ...)
  2004-07-20 15:15 ` [Bug c++/12625] " giovannibajo at libero dot it
@ 2004-07-22  3:22 ` pinskia at gcc dot gnu dot org
  2004-10-13 12:35 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-07-22  3:22 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.5.0                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


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

* [Bug c++/12625] bitfields which have sizes that are powers of 8 missed by -Wparentheses
  2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
                   ` (7 preceding siblings ...)
  2004-07-22  3:22 ` pinskia at gcc dot gnu dot org
@ 2004-10-13 12:35 ` pinskia at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-13 12:35 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12625


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

end of thread, other threads:[~2004-10-13 12:35 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-15 18:07 [Bug c/12625] New: bitfields of size 8 missed by -Wparentheses nomura at netapp dot com
2003-10-15 18:09 ` [Bug c/12625] " nomura at netapp dot com
2003-10-15 18:16 ` nomura at netapp dot com
2003-10-15 18:17 ` [Bug c/12625] bitfields which have sizes that are powers of " pinskia at gcc dot gnu dot org
2004-01-19 19:29 ` pinskia at gcc dot gnu dot org
2004-07-20 14:51 ` pinskia at gcc dot gnu dot org
2004-07-20 14:59 ` jsm at polyomino dot org dot uk
2004-07-20 15:15 ` [Bug c++/12625] " giovannibajo at libero dot it
2004-07-22  3:22 ` pinskia at gcc dot gnu dot org
2004-10-13 12:35 ` pinskia at gcc dot gnu dot org

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).