Debian Codegraph @

gcc/testsuite/g++.dg/cpp1z/decomp50.C

raw
1 // PR c++/92106 - ICE with structured bindings and -Wreturn-local-addr.
2 // { dg-do compile { target c++17 } }
3
4 template <typename> struct B;
5 template <typename _Tp> struct B<_Tp *> { typedef _Tp& reference; };
6 struct C {
7 template <typename _Up> using rebind = _Up *;
8 };
9 template <typename _Iterator, typename> class D {
10 public:
11 typename B<_Iterator>::reference operator*();
12 void operator++();
13 };
14
15 template <typename _Iterator, typename _Container>
16 bool operator!=(D<_Iterator, _Container>, D<_Iterator, _Container>);
17 template <typename _Tp> class F {
18 public:
19 typedef _Tp value_type;
20 };
21
22 template <typename _Alloc> struct G {
23 template <typename _Tp> struct H { using type = C::rebind<_Tp>; };
24 using const_pointer = typename H<typename _Alloc::value_type>::type;
25 };
26 template <typename _Tp, typename _Alloc = F<_Tp>> class I {
27 typedef D<typename G<_Alloc>::const_pointer, int> const_iterator;
28
29 public:
30 const_iterator begin();
31 const_iterator end();
32 };
33
34 struct A {
35 struct J {
36 int name;
37 int value;
38 };
39 I<J> members;
40 template <typename Key> const int *find(Key) {
41 for (const auto &[name, value] : members)
42 // See <https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01107.html>
43 // for why we don't warn here.
44 return &value; // { dg-bogus "address of local variable" }
45 return nullptr;
46 }
47 };
48 int main() {
49 A a;
50 a.find("");
51 }