Bug 4319 - short accepted on typedef'd char
Summary: short accepted on typedef'd char
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 2.96 (redhat)
: P3 normal
Target Milestone: ---
Assignee: Joseph S. Myers
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2001-09-13 13:26 UTC by jfoster
Modified: 2003-07-25 17:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
bad.c (59 bytes, application/octet-stream)
2003-05-21 15:16 UTC, jfoster
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jfoster 2001-09-13 13:26:01 UTC
gcc allows ``short'' to appear with a typedef'd char:

typedef unsigned char __u8;
__u8 short slot_tablelen;

is accepted, but

unsigned char short slot_tablelen;

is not, which doesn't make sense to me.  (In C99, short is
not allowed with any typedef'd name -- I'm not sure why it's
allowed in gcc.)

Release:
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-85)

Environment:
redhat 7.1, x86

How-To-Repeat:
gcc bad.c
Comment 1 Joseph S. Myers 2001-09-13 14:01:57 UTC
Responsible-Changed-From-To: unassigned->jsm28
Responsible-Changed-Why: Claiming responsibility for this bug.  The fix is trivial,
    but doing it properly does involve writing a collection
    of testcases for all the valid and invalid uses of type
    specifiers.
Comment 2 Joseph S. Myers 2001-09-13 14:01:57 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed as a bug in current 3.1 CVS.  This case will
    give a warning with -pedantic; there are a lot of cases
    where warnings conditional on -pedantic ought to be
    unconditional warnings or errors, and since this is a case
    of nonsense code it ought to be an unconditional error.
Comment 3 Joseph S. Myers 2002-08-21 09:42:52 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.3.
Comment 4 Joseph S. Myers 2002-08-21 16:31:37 UTC
From: jsm28@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c/4319
Date: 21 Aug 2002 16:31:37 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	jsm28@gcc.gnu.org	2002-08-21 09:31:37
 
 Modified files:
 	gcc            : ChangeLog c-decl.c 
 	gcc/testsuite  : ChangeLog 
 Added files:
 	gcc/testsuite/gcc.dg: typespec-1.c 
 
 Log message:
 	* c-decl.c (grokdeclarator): Make invalid combinations with long,
 	short, signed or unsigned into hard errors.  Fixes PR c/4319.
 	Also make duplicate modifiers such as "short short" into hard
 	errors.
 	
 	testsuite:
 	* gcc.dg/typespec-1.c: New test.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.15225&r2=1.15226
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&r1=1.348&r2=1.349
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2038&r2=1.2039
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/typespec-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1