https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84469
Bug ID: 84469 Summary: [7/8 Regression] GCC rejects valid code in structured binding in range-based-for in template Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: benni.buch at gmail dot com Target Milestone: --- struct A{ template < typename T > void f()const{} }; template < typename > void foo(){ A a[1][1]; for(auto const& [b]: a){ b.f< int >(); } } int main(){ foo< int >(); } Is a valid program. $ g++ -std=c++17 main.cpp main.cpp: In function 'void foo()': main.cpp:10:14: error: expected primary-expression before 'int' b.f< int >(); ^~~ main.cpp:10:13: error: expected ';' before 'int' b.f< int >(); ^~~~ ; $ g++ --version g++ (GCC) 8.0.1 20180219 (experimental) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++-7 -std=c++17 main.cpp main.cpp: In function 'void foo()': main.cpp:10:14: error: expected primary-expression before 'int' b.f< int >(); ^~~ main.cpp:10:14: error: expected ';' before 'int' $ g++-7 --version g++ (GCC) 7.3.1 20180216 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is accepted without the structured binding: struct A{ template < typename T > void f()const{} }; template < typename > void foo(){ A a[1]; for(auto const& b: a){ b.f< int >(); // OK } } int main(){ foo< int >(); }