A too large bitfield is a constraint violation of C99 6.7.2.1p3. I think it violates ANSI and K&R too, but I can't check that. Gcc only gives a plain warning, even under -std=c99 -pedantic. Release: 3.0 20010611 (prerelease) Environment: System: SunOS bombur.uio.no 5.8 Generic_108528-03 sun4u sparc SUNW,Ultra-5_10 Architecture: sun4 host: sparc-sun-solaris2.8 build: sparc-sun-solaris2.8 target: sparc-sun-solaris2.8 configured with: ./configure --quiet How-To-Repeat: bash$ echo 'struct { int i : 9999; } x;' > a.c bash$ ./xgcc -B./ -std=c99 -pedantic -o /dev/null -S a.c a.c:1: warning: width of `i' exceeds its type
Responsible-Changed-From-To: unassigned->neil Responsible-Changed-Why: Mine.
State-Changed-From-To: open->closed State-Changed-Why: Fixed for 3.1 with http://gcc.gnu.org/ml/gcc-cvs/2002-01/msg00876.html
State-Changed-From-To: closed->analyzed State-Changed-Why: Patch haad to be reverted. Might be fixed before 3.1, otherwise 3.2.
Confirmed with current branch and mainline (20030710). Neil, I take it your patch was never applid?
Since there was a patch at one point, move the target to 3.4 to get some attention.
Subject: Bug 3347 CVSROOT: /cvs/gcc Module name: gcc Changes by: jsm28@gcc.gnu.org 2003-12-17 00:25:25 Modified files: gcc : ChangeLog c-decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: bitfld-8.c Log message: 2003-12-17 Neil Booth <neil@daikokuya.co.uk> Joseph S. Myers <jsm@polyomino.org.uk> PR c/3347 * c-decl.c (enum_decl_context): Remove BITFIELD. (grokdeclarator): Take bit-field width as an input. Perform bit-field width validation with check_bitfield_type_and_width rather than waiting for finish_struct. (groktypename, groktypename_in_parm_context, start_decl, push_parm_decl, grokfield, start_function): Update calls to grokdeclarator. (check_bitfield_type_and_width): New function. (finish_struct): Move bit-field validation to grokdeclarator and check_bitfield_type_and_width. testsuite: * gcc.dg/bitfld-8.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2012&r2=2.2013 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.459&r2=1.460 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3272&r2=1.3273 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/bitfld-8.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed in 3.4.