This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/18498] New: gcc allows non-integral bitfield types


Hello,

$ cat try.c
int main(void) {
	struct X {
        int s[20] : 1;
        int *p : 2;
        int (*f)(float) : 3;
    } x;
    return 0;
}
$ gcc -W -Wall -Wundef -Wendif-labels -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wdisabled-optimization -std=c99 -pedantic -O2 try.c
try.c: In function `main':
try.c:6: warning: unused variable `x'
$

I would have expected an error (or at least a warning) for the non-int
bitfields. C99, 6.7.2.1/4 says:

  A bit-field shall have a type that is a qualified or unqualified version of
  _Bool, signed int, unsigned int, or some other implementation-defined type.

int [20], int * and int (*)(float) aren't ints. I couldn't find anything about
bit-field extensions in `info gcc', so it doesn't seem to be
implementation-defined.

Is this a bug in gcc or am I missing something?

Lukas

-- 
           Summary: gcc allows non-integral bitfield types
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rwxr-xr-x at gmx dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]