[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
-- jason at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |jason at gcc dot gnu dot org |dot org | Status|NEW |ASSIGNED Last reconfirmed|2008-01-14 01:01:39 |2008-02-13 06:08:21 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #17 from jason at gcc dot gnu dot org 2008-02-13 07:08 --- Subject: Bug 34774 Author: jason Date: Wed Feb 13 07:08:11 2008 New Revision: 132283 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=132283 Log: PR c++/34774 * pt.c (value_dependent_expression_p): Look into DECL_INITIAL of enumerators, too. Added: trunk/gcc/testsuite/g++.dg/template/enum6.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #15 from rguenther at suse dot de 2008-01-16 09:23 --- Subject: Re: [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice On Tue, 15 Jan 2008, tbptbp at gmail dot com wrote: --- Comment #14 from tbptbp at gmail dot com 2008-01-15 20:07 --- I keep bumping into this issue and i'd really appreciate a clue about how to workaround for the time being. As of the analysis, try to avoid non-dependent enum members that double- (or more) -indirectly depends on a dependent enum member. For example by propagating the value manually. Like instead of template int i struct foo { enum { a = i, b = a+1, c = b+2 } do enum { a = i, b = i+1, c = i+3 } Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #16 from tbptbp at gmail dot com 2008-01-16 13:04 --- Much helpful, many thanks. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #14 from tbptbp at gmail dot com 2008-01-15 20:07 --- I keep bumping into this issue and i'd really appreciate a clue about how to workaround for the time being. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #9 from rguenth at gcc dot gnu dot org 2008-01-14 12:35 --- The testcase in comment #3 looks valid(?), at least EDG accepts it. The problem is we try to fold_non_dependent_expr n = n0 max_shift ? max_shift : n0, but substituting n0 makes this expression dependent and we leak template param lists to fold. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added Keywords|ice-on-invalid-code |ice-on-valid-code Priority|P4 |P2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #10 from rguenth at gcc dot gnu dot org 2008-01-14 12:45 --- Reduced testcase: templateint shifts struct shift { enum { n0 = (unsigned)shifts, n = n0 ? 0 : n0, n_comp = -n } x; }; it looks like we substitute n into -n but do not stop substituting once we hit a dependent expression (n0). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #11 from rguenth at gcc dot gnu dot org 2008-01-14 12:46 --- Paolo, can you have a look here? ;) -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||pcarlini at suse dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #12 from tbptbp at gmail dot com 2008-01-14 12:47 --- Subject: Re: [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice On 14 Jan 2008 12:35:51 -, rguenth at gcc dot gnu dot org [EMAIL PROTECTED] wrote: The testcase in comment #3 looks valid(?), at least EDG accepts it. The problem is we try to fold_non_dependent_expr n = n0 max_shift ? max_shift : n0, but substituting n0 makes this expression dependent and we leak template param lists to fold. I'm no language lawyer, but the whole exercise is supposed to be valid. It has been mutilated for msvc2k5, and it works there. It also works with g++ when it doesn't fault (that is when i use an alternative implementation). Icc 10.1 doesn't complain either before crashing ;) So, to me, with my rosy teinted glasses strapped on, it has never been an ice-on-invalid. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #13 from pcarlini at suse dot de 2008-01-14 13:29 --- I will, but I don't make promises... -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #2 from rguenth at gcc dot gnu dot org 2008-01-13 19:17 --- This is the same issue as PR31714 (which occurs only on the 4.1 branch). #0 0x084c1ddd in operand_equal_p (arg0=0xb7d275b0, arg1=0xb7d275cc, flags=0) at /home/richard/src/trunk/gcc/fold-const.c:3015 #1 0x084c4664 in operand_equal_p (arg0=0xb7d23be0, arg1=0xb7d23c20, flags=0) at /home/richard/src/trunk/gcc/fold-const.c:3157 #2 0x084c48d0 in operand_equal_p (arg0=0xb7d2806c, arg1=0xb7d28090, flags=0) at /home/richard/src/trunk/gcc/fold-const.c:3162 #3 0x0853fcb1 in fold_ternary (code=COND_EXPR, type=0xb7c84548, op0=0xb7d25550, op1=0xb7d2806c, op2=0xb7d28090) at /home/richard/src/trunk/gcc/fold-const.c:13018 #4 0x08543a00 in fold_build3_stat (code=COND_EXPR, type=0xb7c84548, op0=0xb7d25550, op1=0xb7d2806c, op2=0xb7d28090) at /home/richard/src/trunk/gcc/fold-const.c:13717 #5 0x084e1cc7 in fold_binary_op_with_conditional_arg (code=GT_EXPR, type=0xb7c84548, op0=0xb7c7f280, op1=0xb7d2747c, cond=0xb7c7f280, arg=0xb7d2747c, cond_first_p=1) at /home/richard/src/trunk/gcc/fold-const.c:6398 #6 0x08506c18 in fold_binary (code=GT_EXPR, type=0xb7c84548, op0=0xb7c7f280, op1=0xb7d2747c) at /home/richard/src/trunk/gcc/fold-const.c:9532 #7 0x08543530 in fold (expr=0xb7d28048) at /home/richard/src/trunk/gcc/fold-const.c:13331 #8 0x0826d088 in fold_if_not_in_template (expr=0xb7d28048) at /home/richard/src/trunk/gcc/cp/tree.c:2728 #9 0x081f7043 in build_binary_op (code=GT_EXPR, orig_op0=0xb7c7f280, (gdb) call debug_tree (arg0) tree_list 0xb7d275b0 value negate_expr 0xb7d23c00 type integer_type 0xb7c842d8 int public type_6 SI size integer_cst 0xb7c73620 constant invariant 32 unit size integer_cst 0xb7c7340c constant invariant 4 align 32 symtab 0 alias set -1 canonical type 0xb7c842d8 precision 32 min integer_cst 0xb7c735cc -2147483648 max integer_cst 0xb7c735e8 2147483647 pointer_to_this pointer_type 0xb7c8d8f0 arg 0 template_parm_index 0xb7c78e34 type integer_type 0xb7c842d8 int readonly constant invariant index 0 level 1 orig_level 1 we leak template args to middle-end fold. 3.3 emits an error: mf/unit.h: In instantiation of `metafloat::core::helpers::details::aligner7, metafloat::core::float_t0, 0, 0, CAT_NRM ': mf/unit.h:108: instantiated from `metafloat::core::helpers::details::normalizer7, metafloat::core::helpers::details::aligner7, metafloat::core::float_t0, 0, 0, CAT_NRM ' metafloat.h:135: instantiated from `metafloat::core::helpers::normalizer7, metafloat::core::float_t0, 0, 0, CAT_NRM, true' metafloat.h:135: instantiated from `metafloat::core::ops::addF0, F1' tf.cc:59: instantiated from here mf/unit.h:84: error: no integral type can represent all of the enumerator values for `metafloat::core::helpers::details::aligner7, metafloat::core::float_t0, 0, 0, CAT_NRM ::anonymous enum' reducing. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||rguenth at gcc dot gnu dot ||org OtherBugsDependingO||31714 nThis|| Keywords||ice-on-invalid-code Known to fail||3.4.6 4.1.3 4.3.0 Known to work||3.3.6 Priority|P3 |P4 Summary|templates, enumerations,|[4.1/4.2/4.3 Regression] |overflow, ice |templates, enumerations, ||overflow, ice Target Milestone|--- |4.1.3 Version|unknown |4.3.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #3 from rguenth at gcc dot gnu dot org 2008-01-13 19:24 --- Reduced testcase that is accepted by 3.3 and 3.4 w/o diagnostic but ICEs starting with 4.0. typedef unsigned int op_type_u_t; typedef op_type_u_t op_type_t; templateint shifts, op_type_u_t sig struct shift { enum { num_bits = op_type_u_t(sizeof(op_type_t) * 8), max_shift = num_bits - 1u, is_left = shifts 0 ? true : false, n0 = is_left ? op_type_u_t(-shifts) : op_type_u_t(shifts), n = n0 max_shift ? max_shift : n0, n_comp = max_shift - n } x; }; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #4 from rguenth at gcc dot gnu dot org 2008-01-13 19:29 --- Created an attachment (id=14938) -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14938action=view) unincluded testcase -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #5 from tbptbp at gmail dot com 2008-01-13 19:47 --- Thanks a lot for your investigations. May i ask if the apparent 'quenching' of sign mismatch - and related - warnings (that is if you pile enough templates, due warning are never emitted), is in any way related to this bug? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #6 from rguenther at suse dot de 2008-01-13 21:06 --- Subject: Re: [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice On Sun, 13 Jan 2008, tbptbp at gmail dot com wrote: --- Comment #5 from tbptbp at gmail dot com 2008-01-13 19:47 --- Thanks a lot for your investigations. May i ask if the apparent 'quenching' of sign mismatch - and related - warnings (that is if you pile enough templates, due warning are never emitted), is in any way related to this bug? No idea, but I doubt so ;) Richard. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #7 from tbptbp at gmail dot com 2008-01-13 21:20 --- Subject: Re: [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice On 13 Jan 2008 21:06:07 -, rguenther at suse dot de [EMAIL PROTECTED] wrote: No idea, but I doubt so ;) Fantastic. Now i also see the ldexp sometimes not being folded. I know what i'm doing is kinda evil, but why so much hatred. Snif. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774
[Bug c++/34774] [4.1/4.2/4.3 Regression] templates, enumerations, overflow, ice
--- Comment #8 from manu at gcc dot gnu dot org 2008-01-14 01:01 --- This is confirmed, isn't it? -- manu at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2008-01-14 01:01:39 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34774