Summary: | pedantic switch modifies treatment of non-ISO compliant enumerations | ||
---|---|---|---|
Product: | gcc | Reporter: | Kevin Hall <kevin.hall> |
Component: | c | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | aoliva, gcc-bugs, manu |
Priority: | P2 | Keywords: | FIXME, wrong-code |
Version: | 3.3.3 | ||
Target Milestone: | tree-ssa | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | 3.3.1 3.3.3 3.4.0 4.0.0 3.2.3 | Last reconfirmed: | 2005-12-18 00:39:33 |
Bug Depends on: | |||
Bug Blocks: | 33702 |
Description
Kevin Hall
2004-04-30 20:17:07 UTC
Confirmed with 3.4.0 and 3.5.0. -pedantic should indeed not change the generated code. W. As an aside: the fact that we widen the integer type (without -pedantic) to an 8-byte type is something that changed between 2.95 and 3.2: g/x> /home/bangerth/bin/gcc-3.4-pre/bin/gcc x.c g/x> ./a.out sizeof(MyEnum) = 8 g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/gcc x.c g/x> ./a.out sizeof(MyEnum) = 8 g/x> /home/bangerth/bin/gcc-3.2*/bin/gcc x.c g/x> ./a.out sizeof(MyEnum) = 8 g/x> /home/bangerth/bin/gcc-2*/bin/gcc x.c g/x> ./a.out sizeof(MyEnum) = 4 I don't know, though, whether that was a conscious decision or just by accident. W. Confirmed, in fact there is an XXX in the code now: pedwarn ("ISO C restricts enumerator values to range of `int'"); /* XXX This causes -pedantic to change the meaning of the program. Remove? -zw 2004-03-15 */ value = convert (integer_type_node, value); 1.133 (aoliva 26-Jul-00): value = convert (integer_type_node, value); 1.1 (law 11-Aug-97): pedwarn ("ANSI C restricts enumerator values to range of `int'"); 1.1 (law 11-Aug-97): value = integer_zero_node; revision 1.133 date: 2000/07/26 03:50:56; author: aoliva; state: Exp; lines: +19 -3 * c-decl.c (finish_enum): Convert enumerations that fit in an `int' to `int'. (build_enumerator): In pedantic mode, cast to `int' those that don't. The patch which caused part of the regression: <http://gcc.gnu.org/ml/gcc-patches/2000-07/ msg00993.html>, there might be another which caused the regression which this patch is fixing. *** Bug 35129 has been marked as a duplicate of this bug. *** Cachis, I didn't find this when searching. Anyway, there is a patch that fixes this in PR35129. Subject: Bug 15236 Author: manu Date: Wed Aug 13 10:19:03 2008 New Revision: 139050 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139050 Log: 2008-08-13 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c/15236 * diagnostic.c (pedwarn_at): New. * toplev.h (pedwarn_at): Declare. * c-tree.h (build_enumerator): Update declaration. * c-decl.c (finish_enum): Update comment. (build_enumerator): Take a location parameter. Give a pedwarn but do not perform any conversion. * c-parser.c (c_parser_enum_specifier): Set correct location for enumerator. testsuite/ * gcc.dg/pr15236.c: New. * gcc.dg/torture/pr25183.c: Update. Added: trunk/gcc/testsuite/gcc.dg/pr15236.c Modified: trunk/gcc/ChangeLog trunk/gcc/c-decl.c trunk/gcc/c-parser.c trunk/gcc/c-tree.h trunk/gcc/diagnostic.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.dg/torture/pr25183.c trunk/gcc/toplev.h FIXED in GCC 4.4. |