https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83205
Bug ID: 83205 Summary: ICE on structured binding with ill-formed negative std::tuple_size<T>::value Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jcemmett1 at gmail dot com Target Milestone: --- The following ill-formed code results in an ICE with GCC 8. Needs only -std=c++17. ===== struct Foo { int i; }; namespace std { template <typename T> struct tuple_size; template <> struct tuple_size<Foo> { static constexpr int value = -1; }; } int main() { auto [i] = Foo{}; } ===== Output: GNU C++17 (GCC-Explorer-Build) version 8.0.0 20171128 (experimental) (x86_64-linux-gnu) compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: 6355e9ef8f7b704fe373fdf166e4fd6e <source>: In function 'int main()': 14 : <source>:14:20: internal compiler error: in tree_to_uhwi, at tree.c:6643 auto [i] = Foo{}; ^ mmap: Cannot allocate memory Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. Compiler exited with result code 1 Godbolt link: https://godbolt.org/g/NJ6fLG