public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
@ 2023-09-21 21:53 bugreport0 at proton dot me
  2023-09-21 22:00 ` [Bug c++/111529] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: bugreport0 at proton dot me @ 2023-09-21 21:53 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111529
           Summary: ICE on bool conversion in an unrolled loop condition
                    inside template lambda nested in another template
                    scope
           Product: gcc
           Version: 13.2.0
               URL: https://godbolt.org/z/q64oM6bre
            Status: UNCONFIRMED
          Keywords: c++-lambda, ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugreport0 at proton dot me
  Target Milestone: ---

template <int x>
void f() {
  [](auto c) {
    #pragma GCC unroll 9
    for (int i = c; i; --i) {
    }
  };
}

int main() {
  f<0>();
}


compiles with -std=c++14 but with -std=c++17 generates


<source>: In instantiation of 'void f() [with int x = 0]':
<source>:11:7:   required from here
<source>:5:19: internal compiler error: unexpected expression '(bool)i' of kind
implicit_conv_expr
    5 |     for (int i = c; i; --i) {
      |                   ^
0x1ce7bde internal_error(char const*, ...)
        ???:0
0x8f1d4c finish_for_cond(tree_node*, tree_node*, bool, unsigned short)
        ???:0
0x8d0054 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ???:0
0x8beb17 instantiate_decl(tree_node*, bool, bool)
        ???:0
0x8d993b instantiate_pending_templates(int)
        ???:0
0x7d9f35 c_parse_final_cleanups()
        ???:0
0x98c608 c_common_parse_file()
        ???:0


Making any explicit conversion on the counter inside the condition breaks
compilation with -std=c++14 too.

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

* [Bug c++/111529] [11/12/13/14 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
@ 2023-09-21 22:00 ` pinskia at gcc dot gnu.org
  2023-09-21 22:09 ` bugreport0 at proton dot me
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 22:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
      Known to fail|                            |11.1.0
      Known to work|                            |10.1.0
   Last reconfirmed|                            |2023-09-21
     Ever confirmed|0                           |1
   Target Milestone|---                         |11.5
            Summary|ICE on bool conversion in   |[11/12/13/14 Regression]
                   |an unrolled loop condition  |ICE on bool conversion in
                   |inside template lambda      |an unrolled loop condition
                   |nested in another template  |inside template lambda
                   |scope                       |nested in another template
                   |                            |scope

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Slightly more reduced:
```
template <int>
void f() {
  []<int>() {
    #pragma GCC unroll 9
    for (int i = 1; i; --i) {
    }
  };
}

int main() {
  f<0>();
}
```

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

* [Bug c++/111529] [11/12/13/14 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
  2023-09-21 22:00 ` [Bug c++/111529] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
@ 2023-09-21 22:09 ` bugreport0 at proton dot me
  2023-09-21 22:12 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bugreport0 at proton dot me @ 2023-09-21 22:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Maxim Plyushkin <bugreport0 at proton dot me> ---
It appears that this regression happened between 8.3 and 8.4, not between 10.1
and 11.1.

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

* [Bug c++/111529] [11/12/13/14 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
  2023-09-21 22:00 ` [Bug c++/111529] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
  2023-09-21 22:09 ` bugreport0 at proton dot me
@ 2023-09-21 22:12 ` pinskia at gcc dot gnu.org
  2023-09-21 22:15 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|10.1.0                      |

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Maxim Plyushkin from comment #2)
> It appears that this regression happened between 8.3 and 8.4, not between
> 10.1 and 11.1.

Oh the default C++ version changed between 10 and 11 ...

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

* [Bug c++/111529] [11/12/13/14 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
                   ` (2 preceding siblings ...)
  2023-09-21 22:12 ` pinskia at gcc dot gnu.org
@ 2023-09-21 22:15 ` pinskia at gcc dot gnu.org
  2023-09-22 13:01 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 22:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |8.3.0
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=89576
      Known to fail|                            |8.4.0

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
So it might be the patch which fixed PR 89576 .

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

* [Bug c++/111529] [11/12/13/14 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
                   ` (3 preceding siblings ...)
  2023-09-21 22:15 ` pinskia at gcc dot gnu.org
@ 2023-09-22 13:01 ` cvs-commit at gcc dot gnu.org
  2024-05-08 12:16 ` [Bug c++/111529] [11/12/13 " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-09-22 13:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:9c62af101e11e1cce573c2b3d2e18b403412dbc8

commit r14-4229-g9c62af101e11e1cce573c2b3d2e18b403412dbc8
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Sep 22 12:10:11 2023 +0100

    c++: unroll pragma in templates [PR111529]

    We were failing to handle ANNOTATE_EXPR in tsubst_copy_and_build, leading
to
    problems with substitution of any wrapped expressions.

    Let's also not tell users that lambda templates are available in C++14.

            PR c++/111529

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_lambda_declarator_opt): Don't suggest
            -std=c++14 for lambda templates.
            * pt.cc (tsubst_expr): Move ANNOTATE_EXPR handling...
            (tsubst_copy_and_build): ...here.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/unroll-4.C: New test.

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

* [Bug c++/111529] [11/12/13 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
                   ` (4 preceding siblings ...)
  2023-09-22 13:01 ` cvs-commit at gcc dot gnu.org
@ 2024-05-08 12:16 ` rguenth at gcc dot gnu.org
  2024-05-24 13:25 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-08 12:16 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
           Priority|P3                          |P2

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

* [Bug c++/111529] [11/12/13 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
                   ` (5 preceding siblings ...)
  2024-05-08 12:16 ` [Bug c++/111529] [11/12/13 " rguenth at gcc dot gnu.org
@ 2024-05-24 13:25 ` cvs-commit at gcc dot gnu.org
  2024-05-24 13:26 ` 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 @ 2024-05-24 13:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:53cdaa755de57e57ba9e787f232adc3cfde88209

commit r13-8799-g53cdaa755de57e57ba9e787f232adc3cfde88209
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Sep 22 12:10:11 2023 +0100

    c++: unroll pragma in templates [PR111529]

    We were failing to handle ANNOTATE_EXPR in tsubst_copy_and_build, leading
to
    problems with substitution of any wrapped expressions.

    Let's also not tell users that lambda templates are available in C++14.

            PR c++/111529

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_lambda_declarator_opt): Don't suggest
            -std=c++14 for lambda templates.
            * pt.cc (tsubst_expr): Move ANNOTATE_EXPR handling...
            (tsubst_copy_and_build): ...here.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/unroll-4.C: New test.

    (cherry picked from commit 9c62af101e11e1cce573c2b3d2e18b403412dbc8)

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

* [Bug c++/111529] [11/12/13 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
                   ` (6 preceding siblings ...)
  2024-05-24 13:25 ` cvs-commit at gcc dot gnu.org
@ 2024-05-24 13:26 ` cvs-commit at gcc dot gnu.org
  2024-05-24 18:38 ` cvs-commit at gcc dot gnu.org
  2024-05-24 18:41 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-24 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:19827831516023f2dff449af0b228b2d60190a28

commit r12-10468-g19827831516023f2dff449af0b228b2d60190a28
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Sep 22 12:10:11 2023 +0100

    c++: unroll pragma in templates [PR111529]

    We were failing to handle ANNOTATE_EXPR in tsubst_copy_and_build, leading
to
    problems with substitution of any wrapped expressions.

    Let's also not tell users that lambda templates are available in C++14.

            PR c++/111529

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_lambda_declarator_opt): Don't suggest
            -std=c++14 for lambda templates.
            * pt.cc (tsubst_expr): Move ANNOTATE_EXPR handling...
            (tsubst_copy_and_build): ...here.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/unroll-4.C: New test.

    (cherry picked from commit 9c62af101e11e1cce573c2b3d2e18b403412dbc8)

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

* [Bug c++/111529] [11/12/13 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
                   ` (7 preceding siblings ...)
  2024-05-24 13:26 ` cvs-commit at gcc dot gnu.org
@ 2024-05-24 18:38 ` cvs-commit at gcc dot gnu.org
  2024-05-24 18:41 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-24 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:a644775c363979bc25951532819ffa0f244b82f4

commit r11-11448-ga644775c363979bc25951532819ffa0f244b82f4
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Sep 22 12:10:11 2023 +0100

    c++: unroll pragma in templates [PR111529]

    We were failing to handle ANNOTATE_EXPR in tsubst_copy_and_build, leading
to
    problems with substitution of any wrapped expressions.

    Let's also not tell users that lambda templates are available in C++14.

            PR c++/111529

    gcc/cp/ChangeLog:

            * parser.c (cp_parser_lambda_declarator_opt): Don't suggest
            -std=c++14 for lambda templates.
            * pt.c (tsubst_expr): Move ANNOTATE_EXPR handling...
            (tsubst_copy_and_build): ...here.

    gcc/testsuite/ChangeLog:

            * g++.dg/ext/unroll-4.C: New test.

    (cherry picked from commit 9c62af101e11e1cce573c2b3d2e18b403412dbc8)

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

* [Bug c++/111529] [11/12/13 Regression] ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope
  2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
                   ` (8 preceding siblings ...)
  2024-05-24 18:38 ` cvs-commit at gcc dot gnu.org
@ 2024-05-24 18:41 ` jason at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jason at gcc dot gnu.org @ 2024-05-24 18:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 11.5/12.4/13.4/14.

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

end of thread, other threads:[~2024-05-24 18:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-21 21:53 [Bug c++/111529] New: ICE on bool conversion in an unrolled loop condition inside template lambda nested in another template scope bugreport0 at proton dot me
2023-09-21 22:00 ` [Bug c++/111529] [11/12/13/14 Regression] " pinskia at gcc dot gnu.org
2023-09-21 22:09 ` bugreport0 at proton dot me
2023-09-21 22:12 ` pinskia at gcc dot gnu.org
2023-09-21 22:15 ` pinskia at gcc dot gnu.org
2023-09-22 13:01 ` cvs-commit at gcc dot gnu.org
2024-05-08 12:16 ` [Bug c++/111529] [11/12/13 " rguenth at gcc dot gnu.org
2024-05-24 13:25 ` cvs-commit at gcc dot gnu.org
2024-05-24 13:26 ` cvs-commit at gcc dot gnu.org
2024-05-24 18:38 ` cvs-commit at gcc dot gnu.org
2024-05-24 18:41 ` jason 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).