[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-04-16 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

--- Comment #11 from CVS Commits  ---
The master branch has been updated by Jakub Jelinek :

https://gcc.gnu.org/g:20eb7a1891cfd7fa85295a236cebe0322d041edd

commit r11-8209-g20eb7a1891cfd7fa85295a236cebe0322d041edd
Author: Jakub Jelinek 
Date:   Fri Apr 16 09:32:44 2021 +0200

c++: Fix up handling of structured bindings in extract_locals_r [PR99833]

The following testcase ICEs in tsubst_decomp_names because the assumptions
that the structured binding artificial var is followed in DECL_CHAIN by
the corresponding structured binding vars is violated.
I've tracked it to extract_locals* which is done for the constexpr
IF_STMT.  extract_locals_r when it sees a DECL_EXPR adds that decl
into a hash set so that such decls aren't returned from extract_locals*,
but in the case of a structured binding that just means the artificial var
and not the vars corresponding to structured binding identifiers.
The following patch fixes it by pushing not just the artificial var
for structured bindings but also the other vars.

2021-04-16  Jakub Jelinek  

PR c++/99833
* pt.c (extract_locals_r): When handling DECL_EXPR of a structured
binding, add to data.internal also all corresponding structured
binding decls.

* g++.dg/cpp1z/pr99833.C: New test.
* g++.dg/cpp2a/pr99833.C: New test.

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-04-14 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

--- Comment #10 from Patrick Palka  ---
(In reply to Jakub Jelinek from comment #9)
> Created attachment 50591 [details]
> gcc11-pr99833.patch
> 
> Untested fix.  This seems to work for me...

Ah, I hadn't considered that the problem might be in extract_locals_spec. 
You're much farther than I am on this PR :)  Please feel free to take it.

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-04-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

--- Comment #9 from Jakub Jelinek  ---
Created attachment 50591
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50591=edit
gcc11-pr99833.patch

Untested fix.  This seems to work for me...

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-04-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

--- Comment #8 from Jakub Jelinek  ---
And that ICEs since r7-4511-g70f40fea6a317d7be82d1f02defb59381c7752e7 when
structured binding support has been added, first with
internal compiler error: in is_normal_capture_proxy, at cp/lambda.c:271
then is accepted since r8-6835-g6f58bc5825c0d0ff0606b747b01bb2dcff882a1d
and then since r8-7613-g1456e764105702a0bb6c9be13d8eef7f21990a79 ICEs in
tsubst_decomp_names.

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-04-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

--- Comment #7 from Jakub Jelinek  ---
And hopefully valid variant thereof:
struct S { int a, b; };
template 
void
foo ()
{
  [](auto d) { if constexpr (auto [a, b]{d}; sizeof (a) > 0) a++; } (S{});
}
template void foo ();

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-04-14 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek  ---
That reduced:
template 
void
foo ()
{
  [](auto d) { if constexpr (auto [a, b]{d}; a) ; } (0);
}
template void foo ();

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-03-31 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

--- Comment #5 from Patrick Palka  ---
It looks like GCC 10.1 accepts this testcase, and 10.2, 10.3 and 11 reject.

The requires-expression is a red herring, we can trigger the ICE without it:

#include 
template void f() {
  [] (auto x) {
if constexpr (auto [a, b] = std::tuple{x, x}; sizeof(a) > 1)
  ;
  }(0);
}

template void f();

The ICE for this one isn't a regression it seems.

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-03-31 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2

--- Comment #4 from Richard Biener  ---
(In reply to Marek Polacek from comment #2)
> Started with r11-372.  So may be a P1 :(.

But you show GCC 8 has the same issue ...

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-03-30 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

Patrick Palka  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |ppalka at gcc dot 
gnu.org
 Status|NEW |ASSIGNED

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-03-30 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

--- Comment #3 from Marek Polacek  ---
Reduced:

namespace std {
template  struct integral_constant {
  static constexpr int value = __v;
};
template  struct tuple_size;
template  struct tuple_element;
template 
using __tuple_element_t = typename tuple_element<__i, _Tp>::type;
template  class tuple;
template  tuple(_UTypes...) -> tuple<_UTypes...>;
template  class tuple<_T1, _T2> {
public:
  template  tuple(_U1, _U2);
};
template 
struct tuple_size>
: integral_constant {};
template 
struct tuple_element<__i, tuple<_Head, _Tail...>>
: tuple_element<__i - 1, tuple<_Tail...>> {};
template 
struct tuple_element<0, tuple<_Head, _Tail...>> {
  typedef _Head type;
};
template 
__tuple_element_t<__i, tuple<_Elements...>> get(tuple<_Elements...>);
} // namespace std
void f(auto x) {
  [&](auto...) {
auto y = std::tuple{"", x};
if constexpr (auto [_, z] = y; requires { z; })
  ;
  }();
}
auto main() -> int { f(2); }

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-03-30 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

Marek Polacek  changed:

   What|Removed |Added

  Build|-std=c++20  |
 CC||ppalka at gcc dot gnu.org

--- Comment #2 from Marek Polacek  ---
Started with r11-372.  So may be a P1 :(.

[Bug c++/99833] [8/9/10/11 Regression] structured binding + if init + generic lambda = internal compiler error

2021-03-30 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99833

Marek Polacek  changed:

   What|Removed |Added

   Last reconfirmed||2021-03-30
   Keywords||ice-on-valid-code
   Target Milestone|--- |8.5
 Status|UNCONFIRMED |NEW
Summary|structured binding + if |[8/9/10/11 Regression]
   |init + generic lambda = |structured binding + if
   |internal compiler error |init + generic lambda =
   ||internal compiler error
 CC||mpolacek at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Marek Polacek  ---
Confirmed.

$ xg++-7 -c 99833.C -std=c++17 -fconcepts
# ok
$ xg++-8 -c 99833.C -std=c++17 -fconcepts
99833.C: In instantiation of ‘f(auto:1&&) [with auto:1 = int]:: [with auto:2 = {}]’:
99833.C:8:10:   required from ‘auto f(auto:1&&) [with auto:1 = int]’
99833.C:12:13:   required from here
99833.C:6:32: internal compiler error: in tsubst_decomp_names, at cp/pt.c:16673
 if constexpr (auto [_, z] = y; requires { z; })
^~
0xa44cc6 tsubst_decomp_names
/home/mpolacek/src/gcc8/gcc/cp/pt.c:16673
0xa46041 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:16837
0xa4b103 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:17512
0xa46e75 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:16961
0xa45012 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:16714
0xa475be tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:17014
0xa475be tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:17014
0xa45012 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:16714
0xa475be tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:17014
0xa68a40 instantiate_decl(tree_node*, bool, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:24161
0x90b1e3 maybe_instantiate_decl
/home/mpolacek/src/gcc8/gcc/cp/decl2.c:5211
0x90bb8a mark_used(tree_node*, int)
/home/mpolacek/src/gcc8/gcc/cp/decl2.c:5312
0x814c71 build_over_call
/home/mpolacek/src/gcc8/gcc/cp/call.c:8286
0x804e91 build_op_call_1
/home/mpolacek/src/gcc8/gcc/cp/call.c:4589
0x805053 build_op_call(tree_node*, vec**, int)
/home/mpolacek/src/gcc8/gcc/cp/call.c:4618
0xa9a847 finish_call_expr(tree_node*, vec**, bool,
bool, int)
/home/mpolacek/src/gcc8/gcc/cp/semantics.c:2567
0xa503bf tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:18594
0xa4b422 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:17530
0xa4512d tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:16728
0xa45012 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/mpolacek/src/gcc8/gcc/cp/pt.c:16714