Your message dated 21 Jul 2003 23:06:05 +0200 with message-id <[EMAIL PROTECTED]> and subject line Bug#202319: cpp: enum in #if does not cause warning/error has caused the attached Bug report to be marked as done.
This means that you claim that the problem has been dealt with. If this is not the case it is now your responsibility to reopen the Bug report if necessary, and/or fix the problem forthwith. (NB: If you are a system administrator and have no idea what I am talking about this indicates a serious mail system misconfiguration somewhere. Please contact me immediately.) Debian bug tracking system administrator (administrator, Debian Bugs database) -------------------------------------- Received: (at submit) by bugs.debian.org; 21 Jul 2003 18:52:09 +0000 >From [EMAIL PROTECTED] Mon Jul 21 13:44:05 2003 Return-path: <[EMAIL PROTECTED]> Received: from cpe000102d0fe24-cm0f1119830776.cpe.net.cable.rogers.com (thorin.norang.ca) [65.49.144.24] by master.debian.org with esmtp (Exim 3.35 1 (Debian)) id 19efdl-0005gd-00; Mon, 21 Jul 2003 13:44:05 -0500 Received: from gollum.norang.ca ([EMAIL PROTECTED] [192.168.1.5]) by thorin.norang.ca (8.12.9/8.12.9/Debian-4) with ESMTP id h6LIhxsJ005737; Mon, 21 Jul 2003 14:44:00 -0400 Received: from gollum.norang.ca ([EMAIL PROTECTED] [127.0.0.1]) by gollum.norang.ca (8.12.9/8.12.9/Debian-5) with ESMTP id h6LIhxMT030213; Mon, 21 Jul 2003 14:43:59 -0400 Received: (from [EMAIL PROTECTED]) by gollum.norang.ca (8.12.9/8.12.9/Debian-5) id h6LIhxgw030211; Mon, 21 Jul 2003 14:43:59 -0400 Message-Id: <[EMAIL PROTECTED]> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="ISO-8859-1" From: Bernt Hansen <[EMAIL PROTECTED]> To: Debian Bug Tracking System <[EMAIL PROTECTED]> Subject: cpp: enum in #if does not cause warning/error X-Mailer: reportbug 2.19 Date: Mon, 21 Jul 2003 14:43:58 -0400 Delivered-To: [EMAIL PROTECTED] X-Spam-Status: No, hits=-6.0 required=4.0 tests=BAYES_10,HAS_PACKAGE version=2.53-bugs.debian.org_2003_07_20 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_07_20 (1.174.2.15-2003-03-30-exp) Package: cpp Version: 3:3.3-2 Severity: normal Tags: upstream If an enumerated type is used in #if statements no warning/error is given and the TRUE branch of the #if is always executed. Using enum in #if is declared illegal by K&R along with cast and sizeof (page 91, paragraph 2 of 4.11.3 of "The C Programming Language, Second Edition" [ANSI C]). We use enum and #defines fairly interchangeably in header files for project constants and ran into a case where I want to conditionally compile code based on the value of the constant -- which happened to be an enumerated type. If the constant is a #define it works great. If the constant is an enum value it always evaluates the TRUE case of the #if ... #endif which is not obvious when reading the code. ---- sample code follows ---- #include <stdio.h> enum {S=32, T=33}; #define MY T int main(void) { #if (MY == S) printf("MY(%d) == S\n", MY); #else printf("MY(%d) != S\n", MY); #endif return 0; } ---- end of sample code ---- If the enum {S=32, T=33}; is replaced with #define S 32 #define T 33 the code compiles properly. Since normally the constants/enums are lost in some project header file you won't necessarily know if it was created by an enum or a #define and some warning or error message would be appreciated. Many thanks for an awesome compiler guys! Regards, Bernt -- System Information: Debian Release: testing/unstable Architecture: i386 Kernel: Linux gollum 2.4.21-k7 #1 Wed Jul 2 13:30:26 EDT 2003 i686 Locale: LANG=en_CA, LC_CTYPE=en_CA Versions of packages cpp depends on: ii cpp-3.3 1:3.3.1-0pre0 The GNU C preprocessor -- no debconf information --------------------------------------- Received: (at 202319-done) by bugs.debian.org; 21 Jul 2003 21:06:27 +0000 >From [EMAIL PROTECTED] Mon Jul 21 16:06:08 2003 Return-path: <[EMAIL PROTECTED]> Received: from mx01.uni-tuebingen.de [134.2.3.11] by master.debian.org with esmtp (Exim 3.35 1 (Debian)) id 19ehrE-0008TW-00; Mon, 21 Jul 2003 16:06:08 -0500 Received: from juist (semeai.Informatik.Uni-Tuebingen.De [134.2.15.66]) by mx01.uni-tuebingen.de (8.12.3/8.12.3) with ESMTP id h6LL65Su013789 for <[EMAIL PROTECTED]>; Mon, 21 Jul 2003 23:06:06 +0200 Received: from falk by juist with local (Exim 3.36 #1 (Debian)) id 19ehrB-00009a-00 for <[EMAIL PROTECTED]>; Mon, 21 Jul 2003 23:06:05 +0200 X-Face: "iUeUu$b*W_"w?tV83Y3*r:`rh&dRv}$YnZ3,LVeCZSYVuf[Gpo*5%_=/\_!gc_,SS}[~xZ wY77I-M)xHIx:2f56g%/`SOw"Dx%4Xq0&f\Tj~>|QR|vGlU}TBYhiG(K:2<T^ To: [EMAIL PROTECTED] Subject: Re: Bug#202319: cpp: enum in #if does not cause warning/error References: <[EMAIL PROTECTED]> From: Falk Hueffner <[EMAIL PROTECTED]> Date: 21 Jul 2003 23:06:05 +0200 In-Reply-To: <[EMAIL PROTECTED]> Message-ID: <[EMAIL PROTECTED]> Lines: 6 User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.5 (cabbage) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-AntiVirus: checked by AntiVir Milter 1.0.2; AVE 6.20.0.1; VDF 6.20.0.44 Delivered-To: [EMAIL PROTECTED] X-Spam-Status: No, hits=-3.3 required=4.0 tests=BAYES_10,IN_REP_TO,REFERENCES,USER_AGENT_GNUS_UA version=2.53-bugs.debian.org_2003_07_20 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.53-bugs.debian.org_2003_07_20 (1.174.2.15-2003-03-30-exp) Use -Wundef to warn about use of undefined identifiers in #if. The preprocessor has no way of knowing whether an undefined identifier is an enumeration constant, so you'll get warnings about all of them. -- Falk