c/5480: -Wall doesn't issue warning for enumerated type mismatch

olsenc@ichips.intel.com olsenc@ichips.intel.com
Thu Jan 24 11:56:00 GMT 2002


>Number:         5480
>Category:       c
>Synopsis:       -Wall doesn't issue warning for enumerated type mismatch
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 24 11:56:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.0.2
>Organization:
>Environment:
System: Linux ptdl125 2.2.19-6smp-ltd3 #2 SMP Thu Jun 7 19:50:16 PDT 2001 i686 unknown
Architecture: i686

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc-3.0.2/configure --prefix=/usr/intel/pkgs/gcc/3.0.2 --enable-shared --with-gnu-as=/usr/intel/pkgs/gcc/3.0.2/bin/gas --with-gnu-ld --with-ld=/usr/intel/pkgs/gcc/3.0.2/bin/gld
>Description:
Gcc -Wall doesn't issue a warning that an object declared of enumerated
type is compared or assigned to a different enumerated type.

If you're going to go to the trouble to ensure that all members of an
enumerated type are handled in a switch block, why not cover this case?

Although I marked this as non-critical, this has burned a few of us due to
similar naming for enumerated type choices.

>How-To-Repeat:

typedef enum { SQUARE, HEXAGON, PENTAGON } Polygon;
typedef enum { CAT, DOG, AARDVARK } Animal;

int main(int argc, char **argv)
{
   Polygon foo = PENTAGON;

   if (foo == AARDVARK)
       exit(AARDVARK);
   else
       exit(0);
}
>Fix:
I think a warning should be issued for this case.
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list