public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101765] New: ICE when using a VLA inside of a coroutine
@ 2021-08-03 19:49 kacper.slominski72 at gmail dot com
2021-08-04 8:37 ` [Bug c++/101765] " iains at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: kacper.slominski72 at gmail dot com @ 2021-08-03 19:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
Bug ID: 101765
Summary: ICE when using a VLA inside of a coroutine
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kacper.slominski72 at gmail dot com
Target Milestone: ---
The following code, when compiled with "-std=c++20 -fcoroutines" (on GCC
versions starting from 10.1 and including trunk) causes an ICE:
#include <coroutine>
struct dummy_coro {
using promise_type = dummy_coro;
bool await_ready() noexcept { return false; }
void await_suspend(std::coroutine_handle<>) noexcept { }
void await_resume() noexcept { }
dummy_coro get_return_object() { return {}; }
dummy_coro initial_suspend() { return {}; }
dummy_coro final_suspend() noexcept { return {}; }
void return_void() { }
void unhandled_exception() { }
};
dummy_coro foo(int arg) {
char arr[arg];
co_return;
}
Compiler output from GCC 11:
<source>: In function 'dummy_coro foo(int)':
<source>:18:1: internal compiler error: Segmentation fault
18 | }
| ^
0x1786229 internal_error(char const*, ...)
???:0
0x100ff23 wi::lts_p_large(long const*, unsigned int, unsigned int, long const*,
unsigned int)
???:0
0x6a7c06 finish_struct_1(tree_node*)
???:0
0x6a9c8c finish_struct(tree_node*, tree_node*)
???:0
0x6cd958 morph_fn_to_coro(tree_node*, tree_node**, tree_node**)
???:0
0x6fd221 finish_function(bool)
???:0
0x7c47db c_parse_file()
???:0
0x896762 c_common_parse_file()
???:0
Compiler output from GCC trunk:
<source>: In function 'dummy_coro foo(int)':
<source>:18:1: internal compiler error: tree check: expected integer_cst, have
plus_expr in get_len, at tree.h:6066
18 | }
| ^
0x1dadf09 internal_error(char const*, ...)
???:0
0x69f111 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0x739efa finish_struct_1(tree_node*)
???:0
0x73ca54 finish_struct(tree_node*, tree_node*)
???:0
0x77d64c morph_fn_to_coro(tree_node*, tree_node**, tree_node**)
???:0
0x7de6df finish_function(bool)
???:0
0x914885 c_parse_file()
???:0
0xa97472 c_common_parse_file()
???:0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
@ 2021-08-04 8:37 ` iains at gcc dot gnu.org
2021-08-04 17:23 ` kacper.slominski72 at gmail dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2021-08-04 8:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
I am not sure that a VLA can be used in a coroutine (neither can alloca, if I
remember correctly) [so not sure that this is ICE on valid, it could be ICE on
invalid]
Either way, we should not ICE from it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
2021-08-04 8:37 ` [Bug c++/101765] " iains at gcc dot gnu.org
@ 2021-08-04 17:23 ` kacper.slominski72 at gmail dot com
2021-08-04 18:40 ` iains at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: kacper.slominski72 at gmail dot com @ 2021-08-04 17:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
--- Comment #2 from Kacper Słomiński <kacper.slominski72 at gmail dot com> ---
(In reply to Iain Sandoe from comment #1)
> I am not sure that a VLA can be used in a coroutine (neither can alloca, if
> I remember correctly) [so not sure that this is ICE on valid, it could be
> ICE on invalid]
>
> Either way, we should not ICE from it.
Using alloca or __builtin_alloca inside of coroutines compiles fine, but
despite that I think this should be ICE-on-invalid, as I don't see how stack
allocations would work inside of coroutines, since AFAIK the coro frame size
must be known up-front.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
2021-08-04 8:37 ` [Bug c++/101765] " iains at gcc dot gnu.org
2021-08-04 17:23 ` kacper.slominski72 at gmail dot com
@ 2021-08-04 18:40 ` iains at gcc dot gnu.org
2021-10-02 11:15 ` iains at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2021-08-04 18:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
--- Comment #3 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Kacper Słomiński from comment #2)
> (In reply to Iain Sandoe from comment #1)
> > I am not sure that a VLA can be used in a coroutine (neither can alloca, if
> > I remember correctly) [so not sure that this is ICE on valid, it could be
> > ICE on invalid]
> >
> > Either way, we should not ICE from it.
>
> Using alloca or __builtin_alloca inside of coroutines compiles fine,
That's probably an error ;-) ... I recall discussing this with Gor after Jakub
raised the question at a GNU cauldron - with the outcome that the original
implementation (MSVC) errors-out on alloca.
> but
> despite that I think this should be ICE-on-invalid,
yeah, a VLA would mean a (potentially) different frame layout for each call -
which the current implementations do not support.
> as I don't see how stack
> allocations would work inside of coroutines, since AFAIK the coro frame size
> must be known up-front.
It must be a compile-time constant, known before lowering to IR - but we should
not ICE in any case.
( I have not had a chance yet to process this further )
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
` (2 preceding siblings ...)
2021-08-04 18:40 ` iains at gcc dot gnu.org
@ 2021-10-02 11:15 ` iains at gcc dot gnu.org
2021-10-02 11:16 ` iains at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2021-10-02 11:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2021-10-02
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---
For the record, general VLAs are not supported by clang coroutines either.
the following coroutine fails to compile there as well.
//using test-suite convenience headers.
#include "coro.h"
#include "coro1-ret-int-yield-int.h"
struct coro1
foo (int arg) noexcept
{
PRINTF ("foo arg = %d\n", arg);
char arr[arg];
if (arg < 4)
co_return -6174;
else
for (int i = 0; i < arg; ++i) arr[i] = (char) i;
co_yield (int) arr[2];
co_return (int) arr[3];
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
` (3 preceding siblings ...)
2021-10-02 11:15 ` iains at gcc dot gnu.org
@ 2021-10-02 11:16 ` iains at gcc dot gnu.org
2021-10-02 18:40 ` iains at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2021-10-02 11:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
` (4 preceding siblings ...)
2021-10-02 11:16 ` iains at gcc dot gnu.org
@ 2021-10-02 18:40 ` iains at gcc dot gnu.org
2021-10-03 20:04 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: iains at gcc dot gnu.org @ 2021-10-02 18:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
Iain Sandoe <iains at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |iains at gcc dot gnu.org
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
` (5 preceding siblings ...)
2021-10-02 18:40 ` iains at gcc dot gnu.org
@ 2021-10-03 20:04 ` cvs-commit at gcc dot gnu.org
2022-06-28 10:45 ` jakub at gcc dot gnu.org
2023-07-07 9:45 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-03 20:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>:
https://gcc.gnu.org/g:fdf0b6ce6c1cfa1c328c0c40473c71ca11fd8303
commit r12-4103-gfdf0b6ce6c1cfa1c328c0c40473c71ca11fd8303
Author: Iain Sandoe <iain@sandoe.co.uk>
Date: Sat Oct 2 16:15:38 2021 +0100
coroutines: Fail with a sorry when presented with a VLA [PR 101765].
We do not support this yet.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/101765
gcc/cp/ChangeLog:
* coroutines.cc (register_local_var_uses): Emit a sorry if
we encounter a VLA in the coroutine local variables.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr101765.C: New test.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
` (6 preceding siblings ...)
2021-10-03 20:04 ` cvs-commit at gcc dot gnu.org
@ 2022-06-28 10:45 ` jakub at gcc dot gnu.org
2023-07-07 9:45 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |10.5
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/101765] ICE when using a VLA inside of a coroutine
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
` (7 preceding siblings ...)
2022-06-28 10:45 ` jakub at gcc dot gnu.org
@ 2023-07-07 9:45 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 9:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101765
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |---
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-07-07 9:45 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-03 19:49 [Bug c++/101765] New: ICE when using a VLA inside of a coroutine kacper.slominski72 at gmail dot com
2021-08-04 8:37 ` [Bug c++/101765] " iains at gcc dot gnu.org
2021-08-04 17:23 ` kacper.slominski72 at gmail dot com
2021-08-04 18:40 ` iains at gcc dot gnu.org
2021-10-02 11:15 ` iains at gcc dot gnu.org
2021-10-02 11:16 ` iains at gcc dot gnu.org
2021-10-02 18:40 ` iains at gcc dot gnu.org
2021-10-03 20:04 ` cvs-commit at gcc dot gnu.org
2022-06-28 10:45 ` jakub at gcc dot gnu.org
2023-07-07 9:45 ` rguenth 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).