Bug 3347 - Too large bitfields should be errors
Summary: Too large bitfields should be errors
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.0
: P3 normal
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2001-06-21 13:06 UTC by Hallvard B Furuseth
Modified: 2003-12-19 17:05 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-11-03 04:13:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hallvard B Furuseth 2001-06-21 13:06:00 UTC
	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
Comment 1 Neil Booth 2002-01-29 09:22:04 UTC
Responsible-Changed-From-To: unassigned->neil
Responsible-Changed-Why: Mine.
Comment 2 Neil Booth 2002-01-29 09:22:04 UTC
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
Comment 3 Neil Booth 2002-02-01 20:55:14 UTC
State-Changed-From-To: closed->analyzed
State-Changed-Why: Patch haad to be reverted.  Might be fixed before 3.1, otherwise 3.2.
Comment 4 Dara Hazeghi 2003-07-11 20:05:17 UTC
Confirmed with current branch and mainline (20030710). Neil, I take it your
patch was never applid?
Comment 5 Andrew Pinski 2003-08-13 03:14:07 UTC
Since there was a patch at one point, move the target to 3.4 to get some attention.
Comment 6 GCC Commits 2003-12-17 00:25:28 UTC
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

Comment 7 Joseph S. Myers 2003-12-19 17:05:47 UTC
Fixed in 3.4.