public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda
@ 2022-04-26 18:41 egor.pugin at gmail dot com
  2022-04-26 18:43 ` [Bug c++/105398] " egor.pugin at gmail dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: egor.pugin at gmail dot com @ 2022-04-26 18:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105398
           Summary: [11/12 Regression][ICE] enum in array in lambda
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: egor.pugin at gmail dot com
  Target Milestone: ---

Works in 10.3, broken in 11.1 till trunk.
https://godbolt.org/z/x3z6WYroE

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

* [Bug c++/105398] [11/12 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
@ 2022-04-26 18:43 ` egor.pugin at gmail dot com
  2022-04-26 19:01 ` mpolacek at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: egor.pugin at gmail dot com @ 2022-04-26 18:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Egor Pugin <egor.pugin at gmail dot com> ---
auto f = [](auto &&m) {
    enum { _,e3,e2,e1,C4,C3,C2,C1 };
    static constexpr int x_coeffs[3][4] = {
        {e1,C2,C3,C4},
        {e2,C1,C3,C4},
        {e3,C1,C2,C4},
    };
};

int main() {
    f(0);
}



<source>: In instantiation of '<lambda(auto:1&&)> [with auto:1 = int]':
<source>:11:6:   required from here
<source>:4:10: internal compiler error: in tsubst_copy, at cp/pt.cc:16910
    4 |         {e1,C2,C3,C4},
      |          ^~

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

* [Bug c++/105398] [11/12 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
  2022-04-26 18:43 ` [Bug c++/105398] " egor.pugin at gmail dot com
@ 2022-04-26 19:01 ` mpolacek at gcc dot gnu.org
  2022-04-26 19:33 ` ppalka at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-26 19:01 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-04-26
     Ever confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
           Priority|P3                          |P2
   Target Milestone|---                         |11.4

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  Started with r11-7993-g9f4c41147a41d0

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

* [Bug c++/105398] [11/12 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
  2022-04-26 18:43 ` [Bug c++/105398] " egor.pugin at gmail dot com
  2022-04-26 19:01 ` mpolacek at gcc dot gnu.org
@ 2022-04-26 19:33 ` ppalka at gcc dot gnu.org
  2022-04-26 19:33 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-26 19:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Looking into it..

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

* [Bug c++/105398] [11/12 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
                   ` (2 preceding siblings ...)
  2022-04-26 19:33 ` ppalka at gcc dot gnu.org
@ 2022-04-26 19:33 ` mpolacek at gcc dot gnu.org
  2022-04-26 19:43 ` ppalka at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-26 19:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The patch above changed

-      if (TREE_CODE (template_type) == ENUMERAL_TYPE && !is_dependent_type
+      if (TREE_CODE (template_type) == ENUMERAL_TYPE
+         && !uses_template_parms (current_nonlambda_scope ())
          && !DECL_ALIAS_TEMPLATE_P (gen_tmpl))

but here current_nonlambda_scope () is ::, a NAMESPACE_DECL, which doesn't have
a type, so is considered type-dependent.  So we don't call tsubst_enum.  That
doesn't look right.

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

* [Bug c++/105398] [11/12 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
                   ` (3 preceding siblings ...)
  2022-04-26 19:33 ` mpolacek at gcc dot gnu.org
@ 2022-04-26 19:43 ` ppalka at gcc dot gnu.org
  2022-04-26 19:55 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-26 19:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #4)
> The patch above changed
> 
> -      if (TREE_CODE (template_type) == ENUMERAL_TYPE && !is_dependent_type
> +      if (TREE_CODE (template_type) == ENUMERAL_TYPE
> +         && !uses_template_parms (current_nonlambda_scope ())
>           && !DECL_ALIAS_TEMPLATE_P (gen_tmpl))
> 
> but here current_nonlambda_scope () is ::, a NAMESPACE_DECL, which doesn't
> have a type, so is considered type-dependent.  So we don't call tsubst_enum.
> That doesn't look right.

Whoops, sorry Marek, didn't know you were already looking into this.  Your
analysis makes sense to me :)

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

* [Bug c++/105398] [11/12 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
                   ` (4 preceding siblings ...)
  2022-04-26 19:43 ` ppalka at gcc dot gnu.org
@ 2022-04-26 19:55 ` mpolacek at gcc dot gnu.org
  2022-04-27 17:09 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-26 19:55 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Testing a fix.

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

* [Bug c++/105398] [11/12 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
                   ` (5 preceding siblings ...)
  2022-04-26 19:55 ` mpolacek at gcc dot gnu.org
@ 2022-04-27 17:09 ` cvs-commit at gcc dot gnu.org
  2022-04-27 17:11 ` [Bug c++/105398] [11 " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-27 17:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:409edcca331296b53842c50d3b789e1b1ccc05e5

commit r12-8290-g409edcca331296b53842c50d3b789e1b1ccc05e5
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Apr 26 16:12:58 2022 -0400

    c++: enum in generic lambda at global scope [PR105398]

    We crash compiling this test since r11-7993 which changed
    lookup_template_class_1 so that we only call tsubst_enum when

      !uses_template_parms (current_nonlambda_scope ())

    But here current_nonlambda_scope () is the global NAMESPACE_DECL ::, which
    doesn't have a type, therefore is considered type-dependent.  So we don't
    call tsubst_enum, and crash in tsubst_copy/CONST_DECL because we didn't
    find the e1 enumerator.

    I don't think any namespace can depend on any template parameter, so
    this patch tweaks uses_template_parms.

            PR c++/105398

    gcc/cp/ChangeLog:

            * pt.cc (uses_template_parms): Return false for any NAMESPACE_DECL.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/lambda-generic-enum2.C: New test.

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

* [Bug c++/105398] [11 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
                   ` (6 preceding siblings ...)
  2022-04-27 17:09 ` cvs-commit at gcc dot gnu.org
@ 2022-04-27 17:11 ` mpolacek at gcc dot gnu.org
  2022-04-27 17:14 ` cvs-commit at gcc dot gnu.org
  2022-04-27 17:14 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-27 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12 Regression][ICE]     |[11 Regression][ICE] enum
                   |enum in array in lambda     |in array in lambda

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk so far, will backport to 11.4.

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

* [Bug c++/105398] [11 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
                   ` (7 preceding siblings ...)
  2022-04-27 17:11 ` [Bug c++/105398] [11 " mpolacek at gcc dot gnu.org
@ 2022-04-27 17:14 ` cvs-commit at gcc dot gnu.org
  2022-04-27 17:14 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-27 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:3a1358e5f38864bf5688a7b6db1fda482321a77a

commit r11-9941-g3a1358e5f38864bf5688a7b6db1fda482321a77a
Author: Marek Polacek <polacek@redhat.com>
Date:   Tue Apr 26 16:12:58 2022 -0400

    c++: enum in generic lambda at global scope [PR105398]

    We crash compiling this test since r11-7993 which changed
    lookup_template_class_1 so that we only call tsubst_enum when

      !uses_template_parms (current_nonlambda_scope ())

    But here current_nonlambda_scope () is the global NAMESPACE_DECL ::, which
    doesn't have a type, therefore is considered type-dependent.  So we don't
    call tsubst_enum, and crash in tsubst_copy/CONST_DECL because we didn't
    find the e1 enumerator.

    I don't think any namespace can depend on any template parameter, so
    this patch tweaks uses_template_parms.

            PR c++/105398

    gcc/cp/ChangeLog:

            * pt.c (uses_template_parms): Return false for any NAMESPACE_DECL.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/lambda-generic-enum2.C: New test.

    (cherry picked from commit 409edcca331296b53842c50d3b789e1b1ccc05e5)

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

* [Bug c++/105398] [11 Regression][ICE] enum in array in lambda
  2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
                   ` (8 preceding siblings ...)
  2022-04-27 17:14 ` cvs-commit at gcc dot gnu.org
@ 2022-04-27 17:14 ` mpolacek at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-04-27 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-04-27 17:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 18:41 [Bug c++/105398] New: [11/12 Regression][ICE] enum in array in lambda egor.pugin at gmail dot com
2022-04-26 18:43 ` [Bug c++/105398] " egor.pugin at gmail dot com
2022-04-26 19:01 ` mpolacek at gcc dot gnu.org
2022-04-26 19:33 ` ppalka at gcc dot gnu.org
2022-04-26 19:33 ` mpolacek at gcc dot gnu.org
2022-04-26 19:43 ` ppalka at gcc dot gnu.org
2022-04-26 19:55 ` mpolacek at gcc dot gnu.org
2022-04-27 17:09 ` cvs-commit at gcc dot gnu.org
2022-04-27 17:11 ` [Bug c++/105398] [11 " mpolacek at gcc dot gnu.org
2022-04-27 17:14 ` cvs-commit at gcc dot gnu.org
2022-04-27 17:14 ` mpolacek 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).