public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115139] New: Enum inside variadic template class can't define one of self with usage another value from this enum
@ 2024-05-17 14:27 pavel at karpychev dot name
  2024-05-17 14:49 ` [Bug c++/115139] [14 Regression] " ppalka at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pavel at karpychev dot name @ 2024-05-17 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115139
           Summary: Enum inside variadic template class can't define one
                    of self with usage another value from this enum
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pavel at karpychev dot name
  Target Milestone: ---

Created attachment 58227
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58227&action=edit
source, compile command, error, result of -freport-bug

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

* [Bug c++/115139] [14 Regression] Enum inside variadic template class can't define one of self with usage another value from this enum
  2024-05-17 14:27 [Bug c++/115139] New: Enum inside variadic template class can't define one of self with usage another value from this enum pavel at karpychev dot name
@ 2024-05-17 14:49 ` ppalka at gcc dot gnu.org
  2024-05-21 19:54 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-17 14:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.2
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2024-05-17
             Status|UNCONFIRMED                 |ASSIGNED
           Keywords|                            |ice-on-valid-code
            Summary|Enum inside variadic        |[14 Regression] Enum inside
                   |template class can't define |variadic template class
                   |one of self with usage      |can't define one of self
                   |another value from this     |with usage another value
                   |enum                        |from this enum
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, started with r14-4796-g3e3d73ed5e85e7.  Interestingly
r15-123-gf04dc89a991ddc made us accept this testcase on trunk, so this is a 14
regression only.

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

* [Bug c++/115139] [14 Regression] Enum inside variadic template class can't define one of self with usage another value from this enum
  2024-05-17 14:27 [Bug c++/115139] New: Enum inside variadic template class can't define one of self with usage another value from this enum pavel at karpychev dot name
  2024-05-17 14:49 ` [Bug c++/115139] [14 Regression] " ppalka at gcc dot gnu.org
@ 2024-05-21 19:54 ` cvs-commit at gcc dot gnu.org
  2024-05-21 20:16 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-21 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 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:f0c0bced62b9c728ed1e672747aa234d918da22c

commit r15-759-gf0c0bced62b9c728ed1e672747aa234d918da22c
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue May 21 15:54:10 2024 -0400

    c++: folding non-dep enumerator from current inst [PR115139]

    After the tsubst_copy removal r14-4796-g3e3d73ed5e85e7 GCC 14 ICEs during
    fold_non_dependent_expr for 'e1 | e2' below ultimately because we no
    longer exit early when substituting the CONST_DECLs for e1 and e2 with
    args=NULL_TREE and instead proceed to substitute the class context A<Ts...>
    (also with args=NULL_TREE) which ends up ICEing from tsubst_pack_expansion
    (due to processing_template_decl being cleared).

    Incidentally, the ICE went away on trunk ever since the tsubst_aggr_type
    removal r15-123-gf04dc89a991ddc since it changed the CONST_DECL case of
    tsubst_expr to use tsubst to substitute the context, which short circuits
    for empty args and so avoids the ICE.

    This patch fixes this ICE for GCC 14 by narrowly restoring the early exit
    for empty args that would've happened in tsubst_copy when substituting an
    enumerator CONST_DECL.  We might as well apply this to trunk too, as a
    small optimization.

            PR c++/115139

    gcc/cp/ChangeLog:

            * pt.cc (tsubst_expr) <case CONST_DECL>: Exit early if args
            is empty.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/non-dependent33.C: New test.

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

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

* [Bug c++/115139] [14 Regression] Enum inside variadic template class can't define one of self with usage another value from this enum
  2024-05-17 14:27 [Bug c++/115139] New: Enum inside variadic template class can't define one of self with usage another value from this enum pavel at karpychev dot name
  2024-05-17 14:49 ` [Bug c++/115139] [14 Regression] " ppalka at gcc dot gnu.org
  2024-05-21 19:54 ` cvs-commit at gcc dot gnu.org
@ 2024-05-21 20:16 ` cvs-commit at gcc dot gnu.org
  2024-05-21 20:16 ` ppalka at gcc dot gnu.org
  2024-05-22 11:48 ` pavel at karpychev dot name
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-05-21 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 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:caf43cc9e5c0b3265b55e5a0dc77fc55e9618c77

commit r14-10226-gcaf43cc9e5c0b3265b55e5a0dc77fc55e9618c77
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue May 21 15:54:10 2024 -0400

    c++: folding non-dep enumerator from current inst [PR115139]

    After the tsubst_copy removal r14-4796-g3e3d73ed5e85e7 GCC 14 ICEs during
    fold_non_dependent_expr for 'e1 | e2' below ultimately because we no
    longer exit early when substituting the CONST_DECLs for e1 and e2 with
    args=NULL_TREE and instead proceed to substitute the class context A<Ts...>
    (also with args=NULL_TREE) which ends up ICEing from tsubst_pack_expansion
    (due to processing_template_decl being cleared).

    Incidentally, the ICE went away on trunk ever since the tsubst_aggr_type
    removal r15-123-gf04dc89a991ddc since it changed the CONST_DECL case of
    tsubst_expr to use tsubst to substitute the context, which short circuits
    for empty args and so avoids the ICE.

    This patch fixes this ICE for GCC 14 by narrowly restoring the early exit
    for empty args that would've happened in tsubst_copy when substituting an
    enumerator CONST_DECL.  We might as well apply this to trunk too, as a
    small optimization.

            PR c++/115139

    gcc/cp/ChangeLog:

            * pt.cc (tsubst_expr) <case CONST_DECL>: Exit early if args
            is empty.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/non-dependent33.C: New test.

    Reviewed-by: Marek Polacek <mpolacek@redhat.com>
    Reviewed-by: Jason Merrill <jason@redhat.com>
    (cherry picked from commit f0c0bced62b9c728ed1e672747aa234d918da22c)

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

* [Bug c++/115139] [14 Regression] Enum inside variadic template class can't define one of self with usage another value from this enum
  2024-05-17 14:27 [Bug c++/115139] New: Enum inside variadic template class can't define one of self with usage another value from this enum pavel at karpychev dot name
                   ` (2 preceding siblings ...)
  2024-05-21 20:16 ` cvs-commit at gcc dot gnu.org
@ 2024-05-21 20:16 ` ppalka at gcc dot gnu.org
  2024-05-22 11:48 ` pavel at karpychev dot name
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-05-21 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug c++/115139] [14 Regression] Enum inside variadic template class can't define one of self with usage another value from this enum
  2024-05-17 14:27 [Bug c++/115139] New: Enum inside variadic template class can't define one of self with usage another value from this enum pavel at karpychev dot name
                   ` (3 preceding siblings ...)
  2024-05-21 20:16 ` ppalka at gcc dot gnu.org
@ 2024-05-22 11:48 ` pavel at karpychev dot name
  4 siblings, 0 replies; 6+ messages in thread
From: pavel at karpychev dot name @ 2024-05-22 11:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Pavel <pavel at karpychev dot name> ---
Thank you for the fix!

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

end of thread, other threads:[~2024-05-22 11:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-17 14:27 [Bug c++/115139] New: Enum inside variadic template class can't define one of self with usage another value from this enum pavel at karpychev dot name
2024-05-17 14:49 ` [Bug c++/115139] [14 Regression] " ppalka at gcc dot gnu.org
2024-05-21 19:54 ` cvs-commit at gcc dot gnu.org
2024-05-21 20:16 ` cvs-commit at gcc dot gnu.org
2024-05-21 20:16 ` ppalka at gcc dot gnu.org
2024-05-22 11:48 ` pavel at karpychev dot name

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).