From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CF82B3854835; Thu, 18 Mar 2021 17:47:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF82B3854835 From: "csaba_22 at yahoo dot co.uk" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/99650] New: ICE when trying to form reference to void in structured binding Date: Thu, 18 Mar 2021 17:47:39 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: csaba_22 at yahoo dot co.uk X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Mar 2021 17:47:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99650 Bug ID: 99650 Summary: ICE when trying to form reference to void in structured binding Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: csaba_22 at yahoo dot co.uk Target Milestone: --- Created attachment 50423 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50423&action=3Dedit gzipped preprocessor output The following code leads to an internal compiler error: #include #include #include struct Cow{}; struct Dog{}; struct Horse{}; // of course template struct meow{ template decltype(auto) get() { if constexpr (Idx =3D=3D 0) { return Cow{}; } else if constexpr (Idx =3D=3D 1) { return Dog{}; } else if constexpr (Idx =3D=3D 2) { return Horse{}; } } }; template meow kitty() { return meow{}; } namespace std { template struct tuple_size< meow > : std::integral_constant {}; template< std::size_t Idx, class... Ts > struct tuple_element< Idx, meow > { using type =3D decltype( std::declval< meow >().template get() ); }; } int main(int argc, char const *argv[]) { auto && [ moo, woof, neigh, vv ] =3D kitty(); } $ g++ -v g++ -g -std=3Dgnu++17 -fdiagnostics-color -g=20 tuple-protocol-template.cpp -o tuple-protocol-template Using built-in specs. COLLECT_GCC=3Dg++ COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=3Dnvptx-none OFFLOAD_TARGET_DEFAULT=3D1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=3Dfile:///usr/share/doc/gcc-7/README.Bu= gs --enable-languages=3Dc,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=3D/u= sr --with-gcc-major-version-only --program-suffix=3D-7 --program-prefix=3Dx86_64-linux-gnu- --enable-shared --enable-linker-build-= id --libexecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --libdir=3D/usr/lib --enable-nls --enable-bootstrap --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-libstdcxx-time=3Dyes --with-default-libstdcxx-abi=3Dnew --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=3Dauto --enable-multiarch --disable-werror --with-arch-32=3Di686 --with-abi=3Dm64 --with-multilib-list=3Dm32,m64,mx32 --enable-multilib --with-tune=3Dgeneric --enable-offload-targets=3Dnvptx-none --without-cuda-driver --enable-checking=3Drelease --build=3Dx86_64-linux-gnu --host=3Dx86_64-linu= x-gnu --target=3Dx86_64-linux-gnu Thread model: posix gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) tuple-protocol-template.cpp: In function =E2=80=98int main(int, const char*= *)=E2=80=99: tuple-protocol-template.cpp:43:69: internal compiler error: in build_target_expr_with_type, at cp/tree.c:722 auto && [ moo, woof, neigh, vv ] =3D kitty(); ^ Also fails with: * gcc version 11.0.1 20210317 (experimental) (Compiler-Explorer-Build) * GNU C++17 (Compiler-Explorer-Build) version 10.2.0 (x86_64-linux-gnu) compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.= 1.4, MPC version 1.0.3, isl version isl-0.18-GMP * GNU C++17 (Compiler-Explorer-Build) version 9.3.0 (x86_64-linux-gnu) compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.= 1.4, MPC version 1.0.3, isl version isl-0.18-GMP * GNU C++17 (Compiler-Explorer-Build) version 8.3.0 (x86_64-linux-gnu) compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.= 1.4, MPC version 1.0.3, isl version isl-0.18-GMP * GNU C++14 (GCC-Explorer-Build) version 7.1.0 (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.16.1-GMP clang 11.0.1 on godbolt reports: :43:33: error: cannot form a reference to 'void' auto && [ moo, woof, neigh, vv ] =3D kitty(); ^ :43:33: note: in implicit initialization of binding declaration 'vv' https://godbolt.org/z/e18Ts6=