From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16378 invoked by alias); 28 Nov 2006 17:21:28 -0000 Received: (qmail 15982 invoked by uid 22791); 28 Nov 2006 17:21:21 -0000 X-Spam-Check-By: sourceware.org Received: from web50807.mail.yahoo.com (HELO web50807.mail.yahoo.com) (206.190.38.116) by sourceware.org (qpsmtpd/0.31) with SMTP; Tue, 28 Nov 2006 17:21:10 +0000 Received: (qmail 36075 invoked by uid 60001); 28 Nov 2006 17:21:07 -0000 X-YMail-OSG: 5efoeH8VM1l_8Oj85DPym2ZgiLnKqMcHAS82poMAYJM.9DTaZ3WOrcSmG4zWVyiNoYuVzhx_R9QyMEFpK_60kvs_EDfyAzXWtL01TH9qhV15aT4ouATh2.e5QIFPHce7rhLI8ZDill7Ra7E- Received: from [69.228.211.144] by web50807.mail.yahoo.com via HTTP; Tue, 28 Nov 2006 09:21:07 PST Date: Tue, 28 Nov 2006 17:21:00 -0000 From: darby johnston Subject: enums, switches, and warnings? To: gcc-help@gcc.gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <704684.35452.qm@web50807.mail.yahoo.com> X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-11/txt/msg00338.txt.bz2 Hi, Just ran across a warning (or actually lack-of) that surprised me a bit; example code: enum A { A0, A1, A2 }; enum B { B0, B1, B2, B3 }; int main(int, char **) { A a = A0; switch (a) { case A0: break; case A1: break; //case B2: break; //case B3: break; } return 0; } Compiling gives: warning: enumeration value ‘A2’ not handled in switch But remove the first comment (B2) and the warning goes away. Then removing the second comment (B3), gives: warning: case value ‘3’ not in enumerated type ‘A’ I know that enums are automatically converted to ints, but shouldn't there be a warning that you're mixing enum types? This is using: gcc version 4.0.3 (Ubuntu 4.0.3-1ubuntu5) Thanks, Darby PS. I would never actually write something like this, it's from a bug I found in my code.