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