public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19618] Does warn if bit-fields exceed the size of bool types
       [not found] <bug-19618-9996@http.gcc.gnu.org/bugzilla/>
@ 2007-01-22  7:58 ` mueller at gcc dot gnu dot org
  2009-02-04 16:17 ` tydeman at tybor dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: mueller at gcc dot gnu dot org @ 2007-01-22  7:58 UTC (permalink / raw)
  To: gcc-bugs



-- 

mueller at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mueller at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


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


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

* [Bug c++/19618] Does warn if bit-fields exceed the size of bool types
       [not found] <bug-19618-9996@http.gcc.gnu.org/bugzilla/>
  2007-01-22  7:58 ` [Bug c++/19618] Does warn if bit-fields exceed the size of bool types mueller at gcc dot gnu dot org
@ 2009-02-04 16:17 ` tydeman at tybor dot com
  2009-02-04 16:31 ` joseph at codesourcery dot com
  2009-02-04 17:15 ` tydeman at tybor dot com
  3 siblings, 0 replies; 8+ messages in thread
From: tydeman at tybor dot com @ 2009-02-04 16:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from tydeman at tybor dot com  2009-02-04 16:16 -------
/*
 * _Bool bit-fields: C99: 6.7.2.1, paragraph 3 along with Defect Report 335.
 * _Bool bit-fields of size up to CHAR_BIT must be supported.
 */
#include <limits.h>             /* CHAR_BIT */

int main(void){
  struct bits {
   int        : 0;
   _Bool      : 0;              /* force alignment */
   _Bool bbf1 : 1;              /* holds values 0 and 1 */ 
   _Bool bbf8 : CHAR_BIT;       /* must be supported */
  } bits;
  return 0;
}

The above code fails to compile in gcc 4.3.2-7
The error message is:
error: width of 'bbf8' exceeds its type

A _Bool is one storage unit, so is CHAR_BIT bits.
Therefore, _Bool bit-fields of size 0, 1, 2, ... CHAR_BIT
must be supported.


-- 

tydeman at tybor dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tydeman at tybor dot com


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


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

* [Bug c++/19618] Does warn if bit-fields exceed the size of bool types
       [not found] <bug-19618-9996@http.gcc.gnu.org/bugzilla/>
  2007-01-22  7:58 ` [Bug c++/19618] Does warn if bit-fields exceed the size of bool types mueller at gcc dot gnu dot org
  2009-02-04 16:17 ` tydeman at tybor dot com
@ 2009-02-04 16:31 ` joseph at codesourcery dot com
  2009-02-04 17:15 ` tydeman at tybor dot com
  3 siblings, 0 replies; 8+ messages in thread
From: joseph at codesourcery dot com @ 2009-02-04 16:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from joseph at codesourcery dot com  2009-02-04 16:30 -------
Subject: Re:  Does warn if bit-fields exceed the size of bool
 types

On Wed, 4 Feb 2009, tydeman at tybor dot com wrote:

> /*
>  * _Bool bit-fields: C99: 6.7.2.1, paragraph 3 along with Defect Report 335.
>  * _Bool bit-fields of size up to CHAR_BIT must be supported.
>  */

I don't know why you think C99 is relevant to a C++ bug report.  As I have 
explained at length before and as we discussed at length at the London 
WG14 meeting, the "width" of a type is the number of value and sign bits, 
so post-TC2 a _Bool:CHAR_BIT bit-field is valid only if the implementation 
defines _Bool to have CHAR_BIT value bits.  GCC defines it to have one 
value bit with the other bits being padding bits and undefined behavior if 
you access a _Bool representation with any of the padding bits having a 
nonzero value (such representations being trap representations).  Thus the 
width of _Bool is 1 with GCC and the diagnostics are required.

As you know, TC2 changed "the number of bits in an object of the type that 
is specified if the colon and expression are omitted" to "the width of an 
object of the type that would be specified were the colon and expression 
omitted". in 6.7.2.1 paragraph 3.

I have no idea what is required by C++ and whether GCC implements the C++ 
requirements correctly or not.


-- 


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


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

* [Bug c++/19618] Does warn if bit-fields exceed the size of bool types
       [not found] <bug-19618-9996@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2009-02-04 16:31 ` joseph at codesourcery dot com
@ 2009-02-04 17:15 ` tydeman at tybor dot com
  3 siblings, 0 replies; 8+ messages in thread
From: tydeman at tybor dot com @ 2009-02-04 17:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from tydeman at tybor dot com  2009-02-04 17:15 -------
Opps. I missed that the bug report was against C++ (I still am learning
bugzilla).  So, ignore my previous comments.


-- 


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


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

* [Bug c++/19618] Does warn if bit-fields exceed the size of bool types
       [not found] <bug-19618-4@http.gcc.gnu.org/bugzilla/>
@ 2013-05-24 11:47 ` paolo.carlini at oracle dot com
  0 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-24 11:47 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|gcc-bugs at gcc dot gnu.org        |
           Assignee|mueller at gcc dot gnu.org         |paolo.carlini at oracle dot com

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Let's resolve this.


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

* [Bug c++/19618] Does warn if bit-fields exceed the size of bool types
  2005-01-25  1:34 [Bug c++/19618] New: " mikerobi at ameritech dot net
  2005-01-25  2:31 ` [Bug c++/19618] " pinskia at gcc dot gnu dot org
  2005-01-25  3:25 ` schlie at comcast dot net
@ 2005-04-27  0:34 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-27  0:34 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-27 00:34 -------
We do error out with the C front-end.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2005-01-25 02:30:56         |2005-04-27 00:34:08
               date|                            |


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


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

* [Bug c++/19618] Does warn if bit-fields exceed the size of bool types
  2005-01-25  1:34 [Bug c++/19618] New: " mikerobi at ameritech dot net
  2005-01-25  2:31 ` [Bug c++/19618] " pinskia at gcc dot gnu dot org
@ 2005-01-25  3:25 ` schlie at comcast dot net
  2005-04-27  0:34 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: schlie at comcast dot net @ 2005-01-25  3:25 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From schlie at comcast dot net  2005-01-25 03:24 -------
(In reply to comment #1)

An interesting question might be how wide is a bool type, I believe C defines it as
having a rank less than char, and preumably at least as wide as an unsigned:1, so
does that imply a warning is appropriate for any bool bit-field greater than 1 bit wide?


-- 


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


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

* [Bug c++/19618] Does warn if bit-fields exceed the size of bool types
  2005-01-25  1:34 [Bug c++/19618] New: " mikerobi at ameritech dot net
@ 2005-01-25  2:31 ` pinskia at gcc dot gnu dot org
  2005-01-25  3:25 ` schlie at comcast dot net
  2005-04-27  0:34 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-25  2:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-01-25 02:30 -------
Confirmed, werid.

(compare_tree_int (w, TYPE_PRECISION (type)) > 0
               && TREE_CODE (type) != ENUMERAL_TYPE
               && TREE_CODE (type) != BOOLEAN_TYPE)


This changed way back in March of 1998 but since the mailing list history does not go back that far, I 
don't know why.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2005-01-25 02:30:56
               date|                            |


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


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

end of thread, other threads:[~2013-05-24 11:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-19618-9996@http.gcc.gnu.org/bugzilla/>
2007-01-22  7:58 ` [Bug c++/19618] Does warn if bit-fields exceed the size of bool types mueller at gcc dot gnu dot org
2009-02-04 16:17 ` tydeman at tybor dot com
2009-02-04 16:31 ` joseph at codesourcery dot com
2009-02-04 17:15 ` tydeman at tybor dot com
     [not found] <bug-19618-4@http.gcc.gnu.org/bugzilla/>
2013-05-24 11:47 ` paolo.carlini at oracle dot com
2005-01-25  1:34 [Bug c++/19618] New: " mikerobi at ameritech dot net
2005-01-25  2:31 ` [Bug c++/19618] " pinskia at gcc dot gnu dot org
2005-01-25  3:25 ` schlie at comcast dot net
2005-04-27  0:34 ` 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).