public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: olsenc@ichips.intel.com
To: gcc-gnats@gcc.gnu.org
Cc: ewallace@ichips.intel.com
Subject: c/5480: -Wall doesn't issue warning for enumerated type mismatch
Date: Thu, 24 Jan 2002 11:56:00 -0000	[thread overview]
Message-ID: <200201241945.LAA17459@ptdl125.ra.intel.com> (raw)


>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:


             reply	other threads:[~2002-01-24 19:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-24 11:56 olsenc [this message]
2002-11-05  8:09 bangerth
2003-04-16 14:33 ehrhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200201241945.LAA17459@ptdl125.ra.intel.com \
    --to=olsenc@ichips.intel.com \
    --cc=ewallace@ichips.intel.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).