public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "csaba_22 at yahoo dot co.uk" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-99650-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650 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=50423&action=edit gzipped preprocessor output The following code leads to an internal compiler error: #include <stdint.h> #include <tuple> #include <string> struct Cow{}; struct Dog{}; struct Horse{}; // of course template <typename ... Ts> struct meow{ template<size_t Idx> decltype(auto) get() { if constexpr (Idx == 0) { return Cow{}; } else if constexpr (Idx == 1) { return Dog{}; } else if constexpr (Idx == 2) { return Horse{}; } } }; template <typename ... Ts> meow<Ts...> kitty() { return meow<Ts...>{}; } namespace std { template<typename ... Ts> struct tuple_size< meow<Ts...> > : std::integral_constant<std::size_t, sizeof...(Ts)> {}; template< std::size_t Idx, class... Ts > struct tuple_element< Idx, meow<Ts...> > { using type = decltype( std::declval< meow<Ts...> >().template get<Idx>() ); }; } int main(int argc, char const *argv[]) { auto && [ moo, woof, neigh, vv ] = kitty<Cow, Dog, Horse, void>(); } $ g++ -v g++ -g -std=gnu++17 -fdiagnostics-color -g tuple-protocol-template.cpp -o tuple-protocol-template Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) tuple-protocol-template.cpp: In function ‘int main(int, const char**)’: 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 ] = kitty<Cow, Dog, Horse, void>(); ^ 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: <source>:43:33: error: cannot form a reference to 'void' auto && [ moo, woof, neigh, vv ] = kitty<Cow, Dog, Horse, void>(); ^ <source>:43:33: note: in implicit initialization of binding declaration 'vv' https://godbolt.org/z/e18Ts6
next reply other threads:[~2021-03-18 17:47 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-18 17:47 csaba_22 at yahoo dot co.uk [this message] 2021-03-18 18:22 ` [Bug c++/99650] " jakub at gcc dot gnu.org 2021-03-18 18:31 ` mpolacek at gcc dot gnu.org 2021-03-18 19:08 ` jakub at gcc dot gnu.org 2021-03-18 20:51 ` csaba_22 at yahoo dot co.uk 2021-03-23 9:24 ` cvs-commit at gcc dot gnu.org 2021-03-30 22:41 ` cvs-commit at gcc dot gnu.org 2021-04-20 23:33 ` cvs-commit at gcc dot gnu.org 2021-04-22 16:52 ` cvs-commit at gcc dot gnu.org 2021-04-22 17:11 ` jakub at gcc dot gnu.org 2021-09-11 14:23 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-99650-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).