https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92106
Bug ID: 92106
Summary: ICE with structured bindings and -Wreturn-local-addr
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
template <typename> struct B;
template <typename _Tp> struct B<_Tp *> { typedef _Tp reference; };
struct C {
template <typename _Up> using rebind = _Up *;
};
template <typename _Iterator, typename> class D {
public:
typename B<_Iterator>::reference operator*();
void operator++();
};
template <typename _Iterator, typename _Container>
bool operator!=(D<_Iterator, _Container>, D<_Iterator, _Container>);
template <typename _Tp> class F {
public:
typedef _Tp value_type;
};
template <typename _Alloc> struct G {
template <typename _Tp> struct H { using type = C::rebind<_Tp>; };
using const_pointer = typename H<typename _Alloc::value_type>::type;
};
template <typename _Tp, typename _Alloc = F<_Tp>> class I {
typedef D<typename G<_Alloc>::const_pointer, int> const_iterator;
public:
const_iterator begin();
const_iterator end();
};
struct A {
struct J {
int name;
int value;
};
I<J> members;
template <typename Key> const int *find(Key) {
for (const auto &[name, value] : members)
return &value;
}
};
int main() {
A a;
a.find("");
}
$ ./cc1plus -quiet -std=c++17 ice.C
ice.C: In instantiation of ‘const int* A::find(Key) [with Key = const char*]’:
ice.C:44:12: required from here
ice.C:39:15: internal compiler error: Segmentation fault
39 | return &value;
| ^~~~~
0x1459c14 crash_signal
/home/marek/src/gcc/gcc/toplev.c:326
0x7f5bd2bc8ebf ???
/usr/src/debug/glibc-2.29-32-g6d8eaf4a25/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x916ac2 cp_fold_maybe_rvalue(tree_node*, bool)
/home/marek/src/gcc/gcc/cp/cp-gimplify.c:2192
0x916da7 c_fully_fold(tree_node*, bool, bool*, bool)
/home/marek/src/gcc/gcc/cp/cp-gimplify.c:2261
0x9c9167 fold_for_warn(tree_node*)
/home/marek/src/gcc/gcc/cp/expr.c:401
0xbd86fe maybe_warn_about_returning_address_of_local
/home/marek/src/gcc/gcc/cp/typeck.c:9278
0xbd8d3b maybe_warn_about_returning_address_of_local
/home/marek/src/gcc/gcc/cp/typeck.c:9359
0xbdb84a check_return_expr(tree_node*, bool*)
/home/marek/src/gcc/gcc/cp/typeck.c:9872
0xb5da8e finish_return_stmt(tree_node*)
/home/marek/src/gcc/gcc/cp/semantics.c:952
0xb09e7a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/marek/src/gcc/gcc/cp/pt.c:17400
0xb0bc6a tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/marek/src/gcc/gcc/cp/pt.c:17602
0xb0c832 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/marek/src/gcc/gcc/cp/pt.c:17692
0xb30012 instantiate_decl(tree_node*, bool, bool)
/home/marek/src/gcc/gcc/cp/pt.c:25178
0xb309cf instantiate_pending_templates(int)
/home/marek/src/gcc/gcc/cp/pt.c:25294
0x9a11bf c_parse_final_cleanups()
/home/marek/src/gcc/gcc/cp/decl2.c:4841
0xc700b4 c_common_parse_file()
/home/marek/src/gcc/gcc/c-family/c-opts.c:1201
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.