public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures.
@ 2024-08-10 14:42 jehelset at gmail dot com
  2024-08-10 14:47 ` [Bug c++/116327] " jehelset at gmail dot com
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: jehelset at gmail dot com @ 2024-08-10 14:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

            Bug ID: 116327
           Summary: ICE in coroutine with parameter preview on lambda with
                    captures.
           Product: gcc
           Version: 14.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jehelset at gmail dot com
  Target Milestone: ---

ICE from `expand_expr_real_1` in `expr.cc:11376` 

Seems to happen after 066c7893eae, in particular:

@@ -4618,13 +4618,8 @@ morph_fn_to_coro (tree orig, tree *resumer, tree
*destroyer)
          if (parm_i->this_ptr || parm_i->lambda_cobj)
            {
              /* We pass a reference to *this to the allocator lookup.  */
-             tree tt = TREE_TYPE (TREE_TYPE (arg));
-             tree this_ref = build1 (INDIRECT_REF, tt, arg);
-             tt = cp_build_reference_type (tt, false);
-             this_ref = convert_to_reference (tt, this_ref, CONV_STATIC,
-                                              LOOKUP_NORMAL , NULL_TREE,
-                                              tf_warning_or_error);
-             vec_safe_push (args, convert_from_reference (this_ref));
+             tree this_ref = cp_build_fold_indirect_ref (arg);
+             vec_safe_push (args, this_ref);
            }
          else
            vec_safe_push (args, convert_from_reference (arg));

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] ICE in coroutine with parameter preview on lambda with captures.
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
@ 2024-08-10 14:47 ` jehelset at gmail dot com
  2024-08-10 15:03 ` jehelset at gmail dot com
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jehelset at gmail dot com @ 2024-08-10 14:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

--- Comment #1 from John Eivind Helset <jehelset at gmail dot com> ---
Created attachment 58899
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58899&action=edit
Reproducer, compile with --std=c++20

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] ICE in coroutine with parameter preview on lambda with captures.
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
  2024-08-10 14:47 ` [Bug c++/116327] " jehelset at gmail dot com
@ 2024-08-10 15:03 ` jehelset at gmail dot com
  2024-08-12 13:36 ` [Bug c++/116327] [14/15 Regression] " ppalka at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jehelset at gmail dot com @ 2024-08-10 15:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

--- Comment #2 from John Eivind Helset <jehelset at gmail dot com> ---
had to revert both changes in 066c7893eae to compile my hobby project without
ICE.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures.
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
  2024-08-10 14:47 ` [Bug c++/116327] " jehelset at gmail dot com
  2024-08-10 15:03 ` jehelset at gmail dot com
@ 2024-08-12 13:36 ` ppalka at gcc dot gnu.org
  2024-08-12 14:33 ` ppalka at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-08-12 13:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org
   Target Milestone|---                         |14.3
            Summary|ICE in coroutine with       |[14/15 Regression] ICE in
                   |parameter preview on lambda |coroutine with parameter
                   |with captures.              |preview on lambda with
                   |                            |captures.
      Known to work|                            |14.1.0
      Known to fail|                            |14.2.0, 15.0

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures.
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (2 preceding siblings ...)
  2024-08-12 13:36 ` [Bug c++/116327] [14/15 Regression] " ppalka at gcc dot gnu.org
@ 2024-08-12 14:33 ` ppalka at gcc dot gnu.org
  2024-08-13  1:56 ` [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210 jehelset at gmail dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-08-12 14:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-08-12
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, the ICE seems to only happen with -O0.  Compiling with optimizations
is OK

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (3 preceding siblings ...)
  2024-08-12 14:33 ` ppalka at gcc dot gnu.org
@ 2024-08-13  1:56 ` jehelset at gmail dot com
  2024-08-13 13:35 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jehelset at gmail dot com @ 2024-08-13  1:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

--- Comment #4 from John Eivind Helset <jehelset at gmail dot com> ---
if compiling my project with 14.2.1 in release mode (cmake / -O3) i got another
ICE from `internal compiler error: in set_parm_rtl, at cfgexpand.cc:1436`.

0x21a7bea internal_error(char const*, ...)
        ???:0
0x703e99 fancy_abort(char const*, int, char const*)
        ???:0
0xbd4dfd expand_function_start(tree_node*)
        ???:0

i didn't try to debug gcc 14.2.1 when compiling in release, but i checked that
i could compile in release without 066c7893eae on master (2b23a444bcf).

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (4 preceding siblings ...)
  2024-08-13  1:56 ` [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210 jehelset at gmail dot com
@ 2024-08-13 13:35 ` ppalka at gcc dot gnu.org
  2024-08-13 14:51 ` jehelset at gmail dot com
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-08-13 13:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Ah, never mind then.  Candidate patch posted for review at:
https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660212.html

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (5 preceding siblings ...)
  2024-08-13 13:35 ` ppalka at gcc dot gnu.org
@ 2024-08-13 14:51 ` jehelset at gmail dot com
  2024-08-15 14:20 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: jehelset at gmail dot com @ 2024-08-13 14:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

--- Comment #6 from John Eivind Helset <jehelset at gmail dot com> ---
Works, thanks.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (6 preceding siblings ...)
  2024-08-13 14:51 ` jehelset at gmail dot com
@ 2024-08-15 14:20 ` cvs-commit at gcc dot gnu.org
  2024-08-15 14:33 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-15 14:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:303bed670af962c01b77a4f0c51de97f70e8167e

commit r15-2932-g303bed670af962c01b77a4f0c51de97f70e8167e
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Aug 15 10:20:18 2024 -0400

    c++/coroutines: fix passing *this to promise type, again [PR116327]

    In r15-2210 we got rid of the unnecessary cast to lvalue reference when
    passing *this to the promise type ctor, and as a drive-by change we also
    simplified the code to use cp_build_fold_indirect_ref.

    But it turns out cp_build_fold_indirect_ref does too much here, namely
    it has a shortcut for returning current_class_ref if the operand is
    current_class_ptr.  The problem with that shortcut is current_class_ref
    might have gotten clobbered earlier if it appeared in the function body,
    since rewrite_param_uses walks and rewrites in-place all local variable
    uses to their corresponding frame copy.

    So later cp_build_fold_indirect_ref for *this will instead return the
    clobbered current_class_ref i.e. *frame_ptr->this, which doesn't make
    sense here since we're in the ramp function and not the actor function
    where frame_ptr is in scope.

    This patch fixes this by using the build_fold_indirect_ref instead of
    cp_build_fold_indirect_ref.

            PR c++/116327
            PR c++/104981
            PR c++/115550

    gcc/cp/ChangeLog:

            * coroutines.cc (morph_fn_to_coro): Use build_fold_indirect_ref
            instead of cp_build_fold_indirect_ref.

    gcc/testsuite/ChangeLog:

            * g++.dg/coroutines/pr104981-preview-this.C: Improve coverage by
            adding a non-static data member use within the coroutine member
            function.
            * g++.dg/coroutines/pr116327-preview-this.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (7 preceding siblings ...)
  2024-08-15 14:20 ` cvs-commit at gcc dot gnu.org
@ 2024-08-15 14:33 ` cvs-commit at gcc dot gnu.org
  2024-08-15 14:39 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-08-15 14:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:63c51e09d160a44fdce1199e8efe9d293f773a2c

commit r14-10586-g63c51e09d160a44fdce1199e8efe9d293f773a2c
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Aug 15 10:20:18 2024 -0400

    c++/coroutines: fix passing *this to promise type, again [PR116327]

    In r15-2210 we got rid of the unnecessary cast to lvalue reference when
    passing *this to the promise type ctor, and as a drive-by change we also
    simplified the code to use cp_build_fold_indirect_ref.

    But it turns out cp_build_fold_indirect_ref does too much here, namely
    it has a shortcut for returning current_class_ref if the operand is
    current_class_ptr.  The problem with that shortcut is current_class_ref
    might have gotten clobbered earlier if it appeared in the function body,
    since rewrite_param_uses walks and rewrites in-place all local variable
    uses to their corresponding frame copy.

    So later cp_build_fold_indirect_ref for *this will instead return the
    clobbered current_class_ref i.e. *frame_ptr->this, which doesn't make
    sense here since we're in the ramp function and not the actor function
    where frame_ptr is in scope.

    This patch fixes this by using the build_fold_indirect_ref instead of
    cp_build_fold_indirect_ref.

            PR c++/116327
            PR c++/104981
            PR c++/115550

    gcc/cp/ChangeLog:

            * coroutines.cc (morph_fn_to_coro): Use build_fold_indirect_ref
            instead of cp_build_fold_indirect_ref.

    gcc/testsuite/ChangeLog:

            * g++.dg/coroutines/pr104981-preview-this.C: Improve coverage by
            adding a non-static data member use within the coroutine member
            function.
            * g++.dg/coroutines/pr116327-preview-this.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>
    (cherry picked from commit 303bed670af962c01b77a4f0c51de97f70e8167e)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (8 preceding siblings ...)
  2024-08-15 14:33 ` cvs-commit at gcc dot gnu.org
@ 2024-08-15 14:39 ` ppalka at gcc dot gnu.org
  2024-08-21 19:02 ` pinskia at gcc dot gnu.org
  2024-09-19 22:21 ` arsen at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-08-15 14:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 14.3, thanks for the bug report.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (9 preceding siblings ...)
  2024-08-15 14:39 ` ppalka at gcc dot gnu.org
@ 2024-08-21 19:02 ` pinskia at gcc dot gnu.org
  2024-09-19 22:21 ` arsen at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-08-21 19:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |indiosmo at gmail dot com

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 116450 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210
  2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
                   ` (10 preceding siblings ...)
  2024-08-21 19:02 ` pinskia at gcc dot gnu.org
@ 2024-09-19 22:21 ` arsen at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: arsen at gcc dot gnu.org @ 2024-09-19 22:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116327

Arsen Arsenović <arsen at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ivor+gccbugzilla at posteo dot ee

--- Comment #11 from Arsen Arsenović <arsen at gcc dot gnu.org> ---
*** Bug 116633 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-09-19 22:21 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-10 14:42 [Bug c++/116327] New: ICE in coroutine with parameter preview on lambda with captures jehelset at gmail dot com
2024-08-10 14:47 ` [Bug c++/116327] " jehelset at gmail dot com
2024-08-10 15:03 ` jehelset at gmail dot com
2024-08-12 13:36 ` [Bug c++/116327] [14/15 Regression] " ppalka at gcc dot gnu.org
2024-08-12 14:33 ` ppalka at gcc dot gnu.org
2024-08-13  1:56 ` [Bug c++/116327] [14/15 Regression] ICE in coroutine with parameter preview on lambda with captures since r15-2210 jehelset at gmail dot com
2024-08-13 13:35 ` ppalka at gcc dot gnu.org
2024-08-13 14:51 ` jehelset at gmail dot com
2024-08-15 14:20 ` cvs-commit at gcc dot gnu.org
2024-08-15 14:33 ` cvs-commit at gcc dot gnu.org
2024-08-15 14:39 ` ppalka at gcc dot gnu.org
2024-08-21 19:02 ` pinskia at gcc dot gnu.org
2024-09-19 22:21 ` arsen 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).