[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 Marek Polacek changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #8 from Marek Polacek --- Should be fixed.
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 --- Comment #7 from Marek Polacek --- Author: mpolacek Date: Tue Jan 19 14:02:40 2016 New Revision: 232562 URL: https://gcc.gnu.org/viewcvs?rev=232562=gcc=rev Log: PR c++/68586 * constexpr.c (clear_cv_cache): New. * cp-gimplify.c (clear_fold_cache): New. * cp-tree.h (clear_cv_cache, clear_fold_cache): Declare. * decl.c (finish_enum_value_list): Call them. * g++.dg/cpp0x/enum30.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp0x/enum30.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/constexpr.c trunk/gcc/cp/cp-gimplify.c trunk/gcc/cp/cp-tree.h trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 --- Comment #5 from Marek Polacek --- GCC6 uses a cache for evaluated constant expressions: 4019 tree 4020 maybe_constant_value (tree t, tree decl) 4021 { 4022 tree ret = cv_cache.get (t); The CONST_DECL x is in the cache, associated with 1 of INTEGER_TYPE. It got there when we were processing the LSHIFT_EXPR (x << 1) of the enum in cp_build_binary_op. At that point, x had INTEGER_TYPE (I guess because enum E wasn't complete yet). Later on, when we're in convert_nontype_argument, this function gets CONST_DECL x already of the enum E type, but we pull out 1 of INTEGER_TYPE from the cache, and I think this discrepancy might be the problem here.
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #4 from Marek Polacek --- This passes with trunk with -std=c++03, because the difference comes from maybe_constant_value in convert_nontype_argument: 6260 /* In C++11, integral or enumeration non-type template arguments can be 6261 arbitrary constant expressions. Pointer and pointer to 6262 member arguments can be general constant expressions that evaluate 6263 to a null value, but otherwise still need to be of a specific form. */ 6264 if (cxx_dialect >= cxx11) 6265 { 6266 if (TREE_CODE (expr) == PTRMEM_CST) 6267 /* A PTRMEM_CST is already constant, and a valid template 6268argument for a parameter of pointer to member type, we just want 6269to leave it in that form rather than lower it to a 6270CONSTRUCTOR. */; 6271 else if (INTEGRAL_OR_ENUMERATION_TYPE_P (type)) 6272 expr = maybe_constant_value (expr); gcc-5 compiles this testcase fine even with -std=c++11 though. It looks as if the difference is that for const_decl 'x' gcc-6's maybe_constant_value returns "1" (integer_cst) while gcc-5's maybe_constant_value returns "1" (enumeral_type E).
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 Marek Polacek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org --- Comment #6 from Marek Polacek --- Another testcase (explicit underlying type): enum E : int { x = 1, y = x << 1 }; template struct A {}; A a; It appears this could be solved by *not* inserting const_decls of enums that haven't been finished into the cv_cache. I don't know how to do that though.
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 Richard Biener changed: What|Removed |Added Priority|P3 |P1
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 Martin Sebor changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2015-11-30 CC||msebor at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Martin Sebor --- Confirmed with today's trunk. Seems to be caused by the merge of the delayed folding work (r230365). Prior versions accept the code without an error.
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 Volker Reichelt changed: What|Removed |Added CC||jason at redhat dot com Known to work||5.2.0 --- Comment #3 from Volker Reichelt --- You're right Martin, The bug indeed appeared with r230365.
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 Richard Biener changed: What|Removed |Added Target Milestone|--- |6.0
[Bug c++/68586] [6 Regression] Enum template parameter wrongly rejected
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68586 Daniel Krügler changed: What|Removed |Added CC||daniel.kruegler@googlemail. ||com --- Comment #1 from Daniel Krügler --- Looks like a regression compared to gcc 5.2.0 to me.