The code below with gcc compiles and the exe prints "Value: 3". With g++, instead, the compilation fails with the following error: main.c:7: error: redefinition of `A' main.c:4: error: `A' previously defined here Regards, Giambattista Bloisi ---- #include <stdio.h> typedef enum { A = 1, B = 2, A } myenum; int main() { myenum a = A; printf("Value: %d\n", (int)a); return 0; }
Confirmed, only a 3.4 regression. Started to work on the mainline: : Search converges between 2004-09-24-014001-trunk (#558) and 2004-09-24-161002-trunk (#559). Started to fail: : Search converges between 2004-01-01-trunk (#437) and 2004-01-17-trunk (#438).
Subject: Re: [3.4 Regression] enum definition accepts values to be overriden On Fri, 3 Jun 2005, pinskia at gcc dot gnu dot org wrote: > Confirmed, only a 3.4 regression. > Started to work on the mainline: > : Search converges between 2004-09-24-014001-trunk (#558) and 2004-09-24-161002-trunk > (#559). I.e., fixed by my fix for bug 17188 <http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02566.html>. This patch is probably safe to backport to 3.4 branch.
Subject: Bug 21899 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: jsm28@gcc.gnu.org 2005-07-28 23:01:31 Modified files: gcc : ChangeLog c-decl.c gcc/testsuite : ChangeLog gcc/testsuite/gcc.dg: decl-3.c Added files: gcc/testsuite/gcc.dg: nested-redef-1.c pr17188-1.c Log message: PR c/17188 PR c/21899 * c-decl.c (diagnose_mismatched_decls): Check for duplicate declarations of enumerators. (start_struct): Check TYPE_SIZE rather than TYPE_FIELDS to check for redefinition. Check for nested redefinition. (finish_struct): Don't check for nested redefinition. (start_enum): Check for nested redefinition. testsuite: * gcc.dg/nested-redef-1.c, gcc.dg/pr17188-1.c: New tests. * gcc.dg/decl-3.c: Adjust expected message. 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.889&r2=2.2326.2.890 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.470.4.20&r2=1.470.4.21 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.414&r2=1.3389.2.415 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/nested-redef-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.60.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr17188-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.60.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/decl-3.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2&r2=1.2.4.1
Fixed on 3.4 branch by backporting patch.
*** Bug 23580 has been marked as a duplicate of this bug. ***