public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99650] New: ICE when trying to form reference to void in structured binding
@ 2021-03-18 17:47 csaba_22 at yahoo dot co.uk
2021-03-18 18:22 ` [Bug c++/99650] " jakub at gcc dot gnu.org
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: csaba_22 at yahoo dot co.uk @ 2021-03-18 17:47 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
@ 2021-03-18 18:22 ` jakub at gcc dot gnu.org
2021-03-18 18:31 ` mpolacek at gcc dot gnu.org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-18 18:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
cvise reduced into:
template <int a> struct b { static constexpr int value = a; };
template <typename c> c e(long);
template <typename c> auto d() -> decltype(e<c>(0));
template <typename> struct tuple_size;
template <unsigned long, typename> struct tuple_element;
template <typename...> struct l { template <int> void get(); };
l<int, int, int, void> f;
template <typename... g> struct tuple_size<l<g...>> : b<sizeof... (g)> {};
template <unsigned long m, class... g> struct tuple_element<m, l<g...>> {
using type = decltype(d<l<>>().get<m>());
};
auto [h, i, j, k] = f;
Another testcase that ICEs the same way:
namespace std {
template<typename T> struct tuple_size;
template<int, typename> struct tuple_element;
}
struct A {
int i;
template <int I> void get() { }
};
template<> struct std::tuple_size<A> { static const int value = 2; };
template<int I> struct std::tuple_element<I,A> { using type = void; };
A a = { 42 };
auto [ x, y ] = a;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
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
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-18 18:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-03-18
Status|UNCONFIRMED |NEW
CC| |mpolacek at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r242377.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
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
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-18 19:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 50425
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50425&action=edit
gcc11-pr99650.patch
Untested fix.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
` (2 preceding siblings ...)
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
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: csaba_22 at yahoo dot co.uk @ 2021-03-18 20:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
--- Comment #4 from Csaba Ráduly <csaba_22 at yahoo dot co.uk> ---
Is this a dup of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79372 ?
https://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg522821.html
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
` (3 preceding siblings ...)
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
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-23 9:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:3e07e7a6a7f34f0ec2f1a3e50ebc52b77de11a30
commit r11-7776-g3e07e7a6a7f34f0ec2f1a3e50ebc52b77de11a30
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 23 10:23:42 2021 +0100
c++: Diagnose references to void in structured bindings [PR99650]
We ICE on the following testcase, because std::tuple_element<...,...>::type
is void and for structured bindings we therefore need to create
void & or void && which is invalid. We created such REFERENCE_TYPE and
later ICEd in the middle-end.
The following patch fixes it by diagnosing that.
2021-03-23 Jakub Jelinek <jakub@redhat.com>
PR c++/99650
* decl.c (cp_finish_decomp): Diagnose void initializers when
using tuple_element and get.
* g++.dg/cpp1z/decomp55.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
` (4 preceding siblings ...)
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
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-30 22:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:d5e379e3fe19362442b5d0ac608fb8ddf67fecd3
commit r10-9621-gd5e379e3fe19362442b5d0ac608fb8ddf67fecd3
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 23 10:23:42 2021 +0100
c++: Diagnose references to void in structured bindings [PR99650]
We ICE on the following testcase, because std::tuple_element<...,...>::type
is void and for structured bindings we therefore need to create
void & or void && which is invalid. We created such REFERENCE_TYPE and
later ICEd in the middle-end.
The following patch fixes it by diagnosing that.
2021-03-23 Jakub Jelinek <jakub@redhat.com>
PR c++/99650
* decl.c (cp_finish_decomp): Diagnose void initializers when
using tuple_element and get.
* g++.dg/cpp1z/decomp55.C: New test.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
` (5 preceding siblings ...)
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
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-20 23:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:dd320787b4eb11521e3ae3f9aa9504b31ee08c36
commit r9-9436-gdd320787b4eb11521e3ae3f9aa9504b31ee08c36
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 23 10:23:42 2021 +0100
c++: Diagnose references to void in structured bindings [PR99650]
We ICE on the following testcase, because std::tuple_element<...,...>::type
is void and for structured bindings we therefore need to create
void & or void && which is invalid. We created such REFERENCE_TYPE and
later ICEd in the middle-end.
The following patch fixes it by diagnosing that.
2021-03-23 Jakub Jelinek <jakub@redhat.com>
PR c++/99650
* decl.c (cp_finish_decomp): Diagnose void initializers when
using tuple_element and get.
* g++.dg/cpp1z/decomp55.C: New test.
(cherry picked from commit d5e379e3fe19362442b5d0ac608fb8ddf67fecd3)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
` (6 preceding siblings ...)
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
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-22 16:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-8 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:6132dc70413163b96955a3ebca33c849eb2eb88e
commit r8-10899-g6132dc70413163b96955a3ebca33c849eb2eb88e
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Mar 23 10:23:42 2021 +0100
c++: Diagnose references to void in structured bindings [PR99650]
We ICE on the following testcase, because std::tuple_element<...,...>::type
is void and for structured bindings we therefore need to create
void & or void && which is invalid. We created such REFERENCE_TYPE and
later ICEd in the middle-end.
The following patch fixes it by diagnosing that.
2021-03-23 Jakub Jelinek <jakub@redhat.com>
PR c++/99650
* decl.c (cp_finish_decomp): Diagnose void initializers when
using tuple_element and get.
* g++.dg/cpp1z/decomp55.C: New test.
(cherry picked from commit d5e379e3fe19362442b5d0ac608fb8ddf67fecd3)
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
` (7 preceding siblings ...)
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
9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-22 17:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug c++/99650] ICE when trying to form reference to void in structured binding
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
` (8 preceding siblings ...)
2021-04-22 17:11 ` jakub at gcc dot gnu.org
@ 2021-09-11 14:23 ` pinskia at gcc dot gnu.org
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-11 14:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99650
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |8.5
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-09-11 14:23 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 17:47 [Bug c++/99650] New: ICE when trying to form reference to void in structured binding csaba_22 at yahoo dot co.uk
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
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).