[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 --- Comment #13 from CVS Commits --- The releases/gcc-9 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:b6678d67c4b7471c25130b6c60a9087e02f31179 commit r9-8290-gb6678d67c4b7471c25130b6c60a9087e02f31179 Author: Jason Merrill Date: Wed Feb 26 13:03:23 2020 -0500 c++: Preserve location in maybe_constant_value. If cxx_eval_outermost_constant_expr doesn't change the argument, we really shouldn't unshare it when we try to fold it again. gcc/cp/ChangeLog 2020-02-26 Jason Merrill PR c++/92852 * constexpr.c (maybe_constant_value): Don't unshare if the cached value is the same as the argument.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 --- Comment #12 from CVS Commits --- The releases/gcc-8 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:90e1d25b60630d45fe1092abeb8f4d7b6c5e2da2 commit r8-10051-g90e1d25b60630d45fe1092abeb8f4d7b6c5e2da2 Author: Jason Merrill Date: Mon Feb 24 11:21:47 2020 -0500 c++: Preserve location in maybe_constant_value. If cxx_eval_outermost_constant_expr doesn't change the argument, we really shouldn't unshare it when we try to fold it again. gcc/cp/ChangeLog 2020-02-24 Jason Merrill PR c++/92852 * constexpr.c (maybe_constant_value): Don't unshare if the cached value is the same as the argument.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 --- Comment #11 from CVS Commits --- The master branch has been updated by Jason Merrill : https://gcc.gnu.org/g:173c8defa6e82f1bc003173b6ee1e4eb2830d1c2 commit r10-6526-g173c8defa6e82f1bc003173b6ee1e4eb2830d1c2 Author: Jason Merrill Date: Fri Feb 7 16:28:20 2020 -0500 c++: Preserve location in maybe_constant_value. If cxx_eval_outermost_constant_expr doesn't change the argument, we really shouldn't unshare it when we try to fold it again. PR c++/92852 * constexpr.c (maybe_constant_value): Don't unshare if the cached value is the same as the argument.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 Jason Merrill changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #10 from Jason Merrill --- Fixed for 8.4/9.3/10.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 --- Comment #9 from CVS Commits --- The releases/gcc-9 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:a4b7cf5865823df4b4df1d840d692dfc83fd0672 commit r9-8175-ga4b7cf5865823df4b4df1d840d692dfc83fd0672 Author: Jason Merrill Date: Thu Jan 23 15:45:36 2020 -0500 c++: Unshare expressions from constexpr cache. Another place we need to unshare cached expressions. PR c++/92852 - ICE with generic lambda and reference var. * constexpr.c (maybe_constant_value): Likewise.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 --- Comment #8 from CVS Commits --- The releases/gcc-8 branch has been updated by Jason Merrill : https://gcc.gnu.org/g:7175893ad8010df1270af884a1810476e51a8cd9 commit r8-9953-g7175893ad8010df1270af884a1810476e51a8cd9 Author: Jason Merrill Date: Thu Jan 23 15:45:36 2020 -0500 c++: Unshare expressions from constexpr cache. Another place we need to unshare cached expressions. PR c++/92852 - ICE with generic lambda and reference var. * constexpr.c (maybe_constant_value): Likewise.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 --- Comment #7 from CVS Commits --- The master branch has been updated by Jason Merrill : https://gcc.gnu.org/g:28a5d5c365044710ba32510b9bec67dd40562154 commit r10-6210-g28a5d5c365044710ba32510b9bec67dd40562154 Author: Jason Merrill Date: Thu Jan 23 15:45:36 2020 -0500 c++: Unshare expressions from constexpr cache. Another place we need to unshare cached expressions. PR c++/92852 - ICE with generic lambda and reference var. * constexpr.c (maybe_constant_value): Likewise.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 Richard Biener changed: What|Removed |Added Priority|P3 |P2
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 Jason Merrill changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 Jakub Jelinek changed: What|Removed |Added Keywords|needs-bisection | CC||jakub at gcc dot gnu.org, ||jason at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- Started with r253266.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #5 from Marek Polacek --- Might be dup/related to bug 91165.
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 --- Comment #4 from Richard Biener --- Aha. Reduced testcase: struct S { int operator<<(const int &); } glob; void foo() { S& message_stream = glob; auto format = [_stream](auto && x) { message_stream << x ;}; format(3); format(4u); }
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 --- Comment #3 from Richard Biener --- Somewhat reduced: #include #include struct S { int operator<<(const int &); }; S glob; void foo() { S& message_stream = glob; auto data = std::make_tuple(3,4u); auto format = [_stream](auto && x) { message_stream << x ;}; std::apply([&](auto const& ...x){(..., format(x));}, data); } with std::make_tuple(3,4) it doesn't reproduce(?!)
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 Richard Biener changed: What|Removed |Added Keywords||needs-reduction --- Comment #2 from Richard Biener --- It's the ADDR_EXPR of std::basic_ostream::operator<< (, _1); std::basic_ostream::operator<< (, _1); I think unnesting doesn't have any code rewriting BLOCK references to BLOCKs outside of the nested function. I guess we simply don't expect there to be any... but then we probably do not expect the outer function to vanish without the inner vanishing as well and the checking code doesn't try to "search" for the BLOCK in the outer function. But the testcase must be somehow more "tricky" because the issue doesn't reproduce with int global; void bar(int &, int); void foo() { int& l = global; auto x = [](auto && y) { bar(l, y); }; x(1); } which shows a similar use in operator(): foo()operator() (const struct __lambda7 * const __closure, const int & x) { struct ostream & message_stream [value-expr: ((const struct __lambda7 *) __closure)->__message_stream]; _1 = *x; std::basic_ostream::operator<< (, _1); } vs. foo()operator() (const struct __lambda0 * const __closure, int & y) { int & l [value-expr: ((const struct __lambda0 *) __closure)->__l]; _1 = *y; bar (, _1); } so maybe the situation is all different. Anyway, testcase needs reduction. My limited C++ fu doesn't even allow to remove use ;) (that variadic stuff)
[Bug c++/92852] [8/9/10 Regression] location references block not in block tree
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92852 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |NEW Known to work||7.5.0 Version|unknown |9.2.0 Keywords||ice-checking, ||needs-bisection Last reconfirmed||2019-12-09 CC||rguenth at gcc dot gnu.org Ever confirmed|0 |1 Summary|location references block |[8/9/10 Regression] |not in block tree |location references block ||not in block tree Target Milestone|--- |8.4 Known to fail||10.0, 8.1.0, 8.3.0, 9.2.0 --- Comment #1 from Richard Biener --- Confirmed. This can lead to compiler memory corruption and all sorts of nasty effects.