Hi, there still seems to be a problem with enums in GCC 3.4.1 (see bug #15069). When you compile the follwing snippet with -O0, everthing works well. However, with -O1, the output is "234" which is wrong. Sorry, if this is a duplicate bug report, but I assumed it would be fixed in GCC 3.4.1. Thanks for your help. Regards, Tobias #include <iostream> enum number {ZERO, ONE, TWO, THREE, FOUR, FIVE}; int main() { number n = FIVE; if((n == ONE) || (n == TWO) || (n == THREE)) { std::cout << "234" << std::endl; } }
Of course, the output should be "123", but that doesn't make a difference...
Confirmed, I must have closed one bug as a dup of that bug thinking they were the same problem when in fact this comes from the shorting part of fold.
Subject: Bug 16372 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: jakub@gcc.gnu.org 2004-07-10 18:23:58 Modified files: gcc : ChangeLog fold-const.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: range-test-1.c gcc/testsuite/g++.dg/opt: range-test-1.C Log message: PR tree-optimization/16372 * fold-const.c (build_range_check): Use TYPE_MODE's precision for enumerals. * gcc.dg/range-test-1.c: New test. * g++.dg/opt/range-test-1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.546&r2=2.2326.2.547 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.322.2.11&r2=1.322.2.12 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.225&r2=1.3389.2.226 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/range-test-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.8.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/range-test-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.8.1
*** Bug 16791 has been marked as a duplicate of this bug. ***
*** Bug 15776 has been marked as a duplicate of this bug. ***
*** Bug 15354 has been marked as a duplicate of this bug. ***
Just to confirm the present state: it works with 3.4.1, but doesn't with mainline. Jakub, what was the reason to apply this only to the 3.4 branch, and not to mainline? W.
The reason is rth's objection against applying this to mainline: http://gcc.gnu.org/ml/gcc-patches/2004-07/msg00978.html
Subject: Bug 16372 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: sayle@gcc.gnu.org 2004-08-25 17:22:10 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/opt: pr16372-1.C pr16693-1.C pr16693-2.C Log message: PR middle-end/16693 PR tree-optimization/16372 * decl.c (finish_enum): Make the precision of the enumerated type the same width as the underlying integer type. * g++.dg/opt/pr16372-1.C: New test case. * g++.dg/opt/pr16693-1.C: New test case. * g++.dg/opt/pr16693-2.C: New test case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.153&r2=1.3892.2.154 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1174.2.22&r2=1.1174.2.23 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.260&r2=1.3389.2.261 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr16372-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr16693-1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr16693-2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
Subject: Bug 16372 CVSROOT: /cvs/gcc Module name: gcc Changes by: sayle@gcc.gnu.org 2004-08-25 20:51:02 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/opt: pr16372-1.C pr16693-1.C pr16693-2.C Log message: PR middle-end/16693 PR tree-optimization/16372 * decl.c (finish_enum): Make the precision of the enumerated type the same width as the underlying integer type. * g++.dg/opt/pr16372-1.C: New test case. * g++.dg/opt/pr16693-1.C: New test case. * g++.dg/opt/pr16693-2.C: New test case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4308&r2=1.4309 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1278&r2=1.1279 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4192&r2=1.4193 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr16372-1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr16693-1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/pr16693-2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
Fixed.
*** Bug 25014 has been marked as a duplicate of this bug. ***