[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Bug 84582 depends on bug 84596, which changed state. Bug 84596 Summary: [8 Regression] internal compiler error: unexpected expression '(bool)c' of kind implicit_conv_expr (cxx_eval_constant_expression) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84596 What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Jakub Jelinek changed: What|Removed |Added CC||tuliom at linux dot vnet.ibm.com --- Comment #11 from Jakub Jelinek --- *** Bug 84788 has been marked as a duplicate of this bug. ***
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Bug 84582 depends on bug 84596, which changed state. Bug 84596 Summary: [8 Regression] internal compiler error: unexpected expression '(bool)c' of kind implicit_conv_expr (cxx_eval_constant_expression) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84596 What|Removed |Added Status|RESOLVED|ASSIGNED Resolution|FIXED |---
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Marek Polacek changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #10 from Marek Polacek --- Should be fixed.
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 --- Comment #9 from Marek Polacek --- Author: mpolacek Date: Thu Mar 1 22:44:54 2018 New Revision: 258116 URL: https://gcc.gnu.org/viewcvs?rev=258116=gcc=rev Log: PR c++/84582 * semantics.c (force_paren_expr): Create a PAREN_EXPR when in a template. (maybe_undo_parenthesized_ref): Unwrap PAREN_EXPR. * typeck2.c (store_init_value): Call fold_non_dependent_expr instead of instantiate_non_dependent_expr. * tree.c (lvalue_kind): Handle PAREN_EXPR like NON_DEPENDENT_EXPR. * g++.dg/cpp1y/auto-fn15.C: Extend testing. * g++.dg/cpp1z/static1.C: New test. * g++.dg/template/static37.C: New test. Added: trunk/gcc/testsuite/g++.dg/cpp1z/static1.C trunk/gcc/testsuite/g++.dg/template/static37.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/semantics.c trunk/gcc/cp/tree.c trunk/gcc/cp/typeck2.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/cpp1y/auto-fn15.C
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Bug 84582 depends on bug 84596, which changed state. Bug 84596 Summary: [8 Regression] internal compiler error: unexpected expression '(bool)c' of kind implicit_conv_expr (cxx_eval_constant_expression) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84596 What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Alexandre Oliva changed: What|Removed |Added CC||aoliva at gcc dot gnu.org Depends on||84596 --- Comment #8 from Alexandre Oliva --- Looks like the constexpr in this testcase involves an implicit_conv_expr, support for which I've just added in the proposed patch for bug 84596. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84596 [Bug 84596] [8 Regression] internal compiler error: unexpected expression '(bool)c' of kind implicit_conv_expr (cxx_eval_constant_expression)
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 --- Comment #7 from Jason Merrill --- (In reply to Marek Polacek from comment #6) > So do you think that we don't want the patch in Comment 3? Correct, that patch is wrong.
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 --- Comment #6 from Marek Polacek --- (In reply to Jason Merrill from comment #5) > (In reply to Jakub Jelinek from comment #2) > > Given: > > class C { > > static const long b = 0; > > static const unsigned c = (b); > > }; > > class D { > > static const long b = 0; > > static const unsigned c = b; > > }; > > template class A { > > static const long b = 0; > > static const unsigned c = (b); > > }; > > template class B { > > static const long b = 0; > > static const unsigned c = b; > > }; > > > > we only reject the A case. > > For D and B there is just INTEGER_CST, and for C and A we have: > > (unsigned int) (long int) *(const long int &) > > because of the parens. > > The reason why it is accepted outside of template and not inside of it is > > that > > cxx_constant_init calls is_nondependent_static_init_expression which calls > > instantiation_dependent_expression_p and that is true in A::c. > > Right, because is value-dependent. I guess force_paren_expr can't do > that transformation in a template. So do you think that we don't want the patch in Comment 3?
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Jason Merrill changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #5 from Jason Merrill --- (In reply to Jakub Jelinek from comment #2) > Given: > class C { > static const long b = 0; > static const unsigned c = (b); > }; > class D { > static const long b = 0; > static const unsigned c = b; > }; > template class A { > static const long b = 0; > static const unsigned c = (b); > }; > template class B { > static const long b = 0; > static const unsigned c = b; > }; > > we only reject the A case. > For D and B there is just INTEGER_CST, and for C and A we have: > (unsigned int) (long int) *(const long int &) > because of the parens. > The reason why it is accepted outside of template and not inside of it is > that > cxx_constant_init calls is_nondependent_static_init_expression which calls > instantiation_dependent_expression_p and that is true in A::c. Right, because is value-dependent. I guess force_paren_expr can't do that transformation in a template.
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Marek Polacek changed: What|Removed |Added Priority|P3 |P1
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 --- Comment #4 from Marek Polacek --- ...with that we get the original ICE in PR84325 back: internal compiler error: unexpected expression ‘(const seconds){operator""_s<'1', '0'>()}’ of kind implicit_conv_expr constexpr static inline seconds time_to_wait{10_s}; so that's another bug that needs to be fixed while at this.
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 --- Comment #3 from Marek Polacek --- It looks like we shouldn't skip the evaluation when ALLOW_NON_CONSTANT is false, similarly to the CONSTANT_CLASS_P case: @@ -5137,10 +5147,10 @@ maybe_constant_init_1 (tree t, tree decl, bool allow_non_constant) t = TREE_OPERAND (t, 1); if (TREE_CODE (t) == TARGET_EXPR) t = TARGET_EXPR_INITIAL (t); - if (!is_nondependent_static_init_expression (t)) + if (allow_non_constant + && (!is_nondependent_static_init_expression (t) + || CONSTANT_CLASS_P (t))) /* Don't try to evaluate it. */; - else if (CONSTANT_CLASS_P (t) && allow_non_constant) -/* No evaluation needed. */; else t = cxx_eval_outermost_constant_expr (t, allow_non_constant, false, decl); if (TREE_CODE (t) == TARGET_EXPR)
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 --- Comment #2 from Jakub Jelinek --- Given: class C { static const long b = 0; static const unsigned c = (b); }; class D { static const long b = 0; static const unsigned c = b; }; template class A { static const long b = 0; static const unsigned c = (b); }; template class B { static const long b = 0; static const unsigned c = b; }; we only reject the A case. For D and B there is just INTEGER_CST, and for C and A we have: (unsigned int) (long int) *(const long int &) because of the parens. The reason why it is accepted outside of template and not inside of it is that cxx_constant_init calls is_nondependent_static_init_expression which calls instantiation_dependent_expression_p and that is true in A::c.
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Marek Polacek changed: What|Removed |Added Status|UNCONFIRMED |ASSIGNED Last reconfirmed||2018-02-27 Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org Ever confirmed|0 |1
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 --- Comment #1 from Marek Polacek --- We have (unsigned int) (long int) *(const long int &) and cxx_constant_value -> maybe_constant_init_1 doesn't evaluate it now: 5154 if (!is_nondependent_static_init_expression (t)) 5155 /* Don't try to evaluate it. */; and that CONVERT_EXPR isn't is_nondependent_static_init_expression.
[Bug c++/84582] [8 Regression] Rejected valid C++ code since r257961
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84582 Martin Liška changed: What|Removed |Added Known to work||7.3.0 Target Milestone|--- |8.0 Known to fail||8.0