public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107417] New: g++ fails to recognize parameter pack in requires-expression
@ 2022-10-26 15:25 jwjagersma at gmail dot com
  2022-10-26 16:32 ` [Bug c++/107417] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jwjagersma at gmail dot com @ 2022-10-26 15:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107417
           Summary: g++ fails to recognize parameter pack in
                    requires-expression
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jwjagersma at gmail dot com
  Target Milestone: ---

Given the following code:

  $ cat fold.cpp
  template<typename... T>
  requires (requires (T x) { x; } and ...)
  auto func(T...) { }

g++ seems to forget that T is a parameter pack:

  $ g++ -std=c++20 fold.cpp
  fold.cpp:2:11: error: operand of fold expression has no unexpanded parameter
packs
      2 | requires (requires (T x) { x; } and ...)
        |           ^~~~~~~~~~~~~~~~~~~~~

This issue is present on both 12.2 and latest 13.0.  Clang and msvc do accept
it.

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

* [Bug c++/107417] g++ fails to recognize parameter pack in requires-expression
  2022-10-26 15:25 [Bug c++/107417] New: g++ fails to recognize parameter pack in requires-expression jwjagersma at gmail dot com
@ 2022-10-26 16:32 ` redi at gcc dot gnu.org
  2022-10-26 19:06 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2022-10-26 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |accepts-invalid,
                   |                            |rejects-valid
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-10-26

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think the underlying issue is that it accepts the pack without expansion:

template<typename... T>
  requires (requires (T x) { x; })
  auto func(T...) { }

And so the error about "no unexpanded parameter packs" is correct, the AST
doesn't contain any. But it should do, the requires-expression is a pack
expression that must be expanded (e.g. in a fold expression).

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

* [Bug c++/107417] g++ fails to recognize parameter pack in requires-expression
  2022-10-26 15:25 [Bug c++/107417] New: g++ fails to recognize parameter pack in requires-expression jwjagersma at gmail dot com
  2022-10-26 16:32 ` [Bug c++/107417] " redi at gcc dot gnu.org
@ 2022-10-26 19:06 ` ppalka at gcc dot gnu.org
  2022-12-04 15:47 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-10-26 19:06 UTC (permalink / raw)
  To: gcc-bugs

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

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
                 CC|                            |ppalka at gcc dot gnu.org

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

* [Bug c++/107417] g++ fails to recognize parameter pack in requires-expression
  2022-10-26 15:25 [Bug c++/107417] New: g++ fails to recognize parameter pack in requires-expression jwjagersma at gmail dot com
  2022-10-26 16:32 ` [Bug c++/107417] " redi at gcc dot gnu.org
  2022-10-26 19:06 ` ppalka at gcc dot gnu.org
@ 2022-12-04 15:47 ` cvs-commit at gcc dot gnu.org
  2022-12-04 15:47 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-04 15:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS 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:079add3ad39d6620d34665dd9c26c21951eb657c

commit r13-4483-g079add3ad39d6620d34665dd9c26c21951eb657c
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sun Dec 4 10:47:24 2022 -0500

    c++: pack in requires-expr parm list [PR107417]

    Here find_parameter_packs_r isn't detecting the pack T inside the
    requires-expr's parameter list ultimately because cp_walk_trees
    deliberately avoids walking the list so as to avoid false positives in
    the unexpanded pack checker.

    But it should still be fine to walk the TREE_TYPE of each parameter,
    which we already need to do from for_each_template_parm_r, and is
    sufficient to fix the testcase.

            PR c++/107417

    gcc/cp/ChangeLog:

            * pt.cc (for_each_template_parm_r) <case REQUIRES_EXPR>: Move
            walking of the TREE_TYPE of each parameter to ...
            * tree.cc (cp_walk_subtrees) <case REQUIRES_EXPR>: ... here.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-requires33.C: New test.

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

* [Bug c++/107417] g++ fails to recognize parameter pack in requires-expression
  2022-10-26 15:25 [Bug c++/107417] New: g++ fails to recognize parameter pack in requires-expression jwjagersma at gmail dot com
                   ` (2 preceding siblings ...)
  2022-12-04 15:47 ` cvs-commit at gcc dot gnu.org
@ 2022-12-04 15:47 ` ppalka at gcc dot gnu.org
  2022-12-19 16:54 ` cvs-commit at gcc dot gnu.org
  2022-12-19 16:56 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-12-04 15:47 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.3

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk so far.

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

* [Bug c++/107417] g++ fails to recognize parameter pack in requires-expression
  2022-10-26 15:25 [Bug c++/107417] New: g++ fails to recognize parameter pack in requires-expression jwjagersma at gmail dot com
                   ` (3 preceding siblings ...)
  2022-12-04 15:47 ` ppalka at gcc dot gnu.org
@ 2022-12-19 16:54 ` cvs-commit at gcc dot gnu.org
  2022-12-19 16:56 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-19 16:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

commit r12-8996-gb428bb449be1bdbbd4000b51bb7c665981dc8c8f
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sun Dec 4 10:47:24 2022 -0500

    c++: pack in requires-expr parm list [PR107417]

    Here find_parameter_packs_r isn't detecting the pack T inside the
    requires-expr's parameter list ultimately because cp_walk_trees
    deliberately avoids walking the list so as to avoid false positives in
    the unexpanded pack checker.

    But it should still be fine to walk the TREE_TYPE of each parameter,
    which we already need to do from for_each_template_parm_r, and is
    sufficient to fix the testcase.

            PR c++/107417

    gcc/cp/ChangeLog:

            * pt.cc (for_each_template_parm_r) <case REQUIRES_EXPR>: Move
            walking of the TREE_TYPE of each parameter to ...
            * tree.cc (cp_walk_subtrees) <case REQUIRES_EXPR>: ... here.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-requires33.C: New test.

    (cherry picked from commit 079add3ad39d6620d34665dd9c26c21951eb657c)

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

* [Bug c++/107417] g++ fails to recognize parameter pack in requires-expression
  2022-10-26 15:25 [Bug c++/107417] New: g++ fails to recognize parameter pack in requires-expression jwjagersma at gmail dot com
                   ` (4 preceding siblings ...)
  2022-12-19 16:54 ` cvs-commit at gcc dot gnu.org
@ 2022-12-19 16:56 ` ppalka at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-12-19 16:56 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12.3/13, thanks for the bug report.

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

end of thread, other threads:[~2022-12-19 16:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-26 15:25 [Bug c++/107417] New: g++ fails to recognize parameter pack in requires-expression jwjagersma at gmail dot com
2022-10-26 16:32 ` [Bug c++/107417] " redi at gcc dot gnu.org
2022-10-26 19:06 ` ppalka at gcc dot gnu.org
2022-12-04 15:47 ` cvs-commit at gcc dot gnu.org
2022-12-04 15:47 ` ppalka at gcc dot gnu.org
2022-12-19 16:54 ` cvs-commit at gcc dot gnu.org
2022-12-19 16:56 ` ppalka 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).