public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101181] New: ICE when using an alias template
@ 2021-06-23 18:02 webrown.cpp at gmail dot com
  2021-06-30 19:25 ` [Bug c++/101181] [11/12 Regression] " mpolacek at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: webrown.cpp at gmail dot com @ 2021-06-23 18:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101181
           Summary: ICE when using an alias template
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: webrown.cpp at gmail dot com
  Target Milestone: ---

The following program produces "Segmentation fault: 11 signal terminated
program cc1plus" when compiled with flags

-std=c++23 -fmodules-ts -pedantic-errors -O0 -c

using gcc trunk version

(Homebrew GCC HEAD-da13e4e_1) 12.0.0 20210623 (experimental)


template< class T
        , bool = requires { typename T::pointer; }
        >
struct p { using type = void; };

template< class T >
struct p<T, true> { using type = T::pointer; };

template< class T > using P = typename p<T>::type;


Without the final alias template, all seems well.

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

* [Bug c++/101181] [11/12 Regression] ICE when using an alias template
  2021-06-23 18:02 [Bug c++/101181] New: ICE when using an alias template webrown.cpp at gmail dot com
@ 2021-06-30 19:25 ` mpolacek at gcc dot gnu.org
  2021-07-08  0:10 ` ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-30 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-06-30
                 CC|                            |mpolacek at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
            Summary|ICE when using an alias     |[11/12 Regression] ICE when
                   |template                    |using an alias template
   Target Milestone|---                         |11.2
           Priority|P3                          |P2

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed, started with r11-3261.

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

* [Bug c++/101181] [11/12 Regression] ICE when using an alias template
  2021-06-23 18:02 [Bug c++/101181] New: ICE when using an alias template webrown.cpp at gmail dot com
  2021-06-30 19:25 ` [Bug c++/101181] [11/12 Regression] " mpolacek at gcc dot gnu.org
@ 2021-07-08  0:10 ` ppalka at gcc dot gnu.org
  2021-07-09 14:22 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-07-08  0:10 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/101181] [11/12 Regression] ICE when using an alias template
  2021-06-23 18:02 [Bug c++/101181] New: ICE when using an alias template webrown.cpp at gmail dot com
  2021-06-30 19:25 ` [Bug c++/101181] [11/12 Regression] " mpolacek at gcc dot gnu.org
  2021-07-08  0:10 ` ppalka at gcc dot gnu.org
@ 2021-07-09 14:22 ` cvs-commit at gcc dot gnu.org
  2021-07-13 14:03 ` cvs-commit at gcc dot gnu.org
  2021-07-13 14:10 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-09 14:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:2c699fd29829cd6115f78238dab7cab74f0a5009

commit r12-2222-g2c699fd29829cd6115f78238dab7cab74f0a5009
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jul 9 10:20:25 2021 -0400

    c++: requires-expr with dependent extra args [PR101181]

    Here we're crashing ultimately because the mechanism for delaying
    substitution into a requires-expression (and constexpr if and pack
    expansions) doesn't expect to see dependent args.  But we end up
    capturing dependent args here during substitution into the default
    template argument as part of coerce_template_parms for the dependent
    specialization p<T>.

    This patch enables the commented out code in add_extra_args for handling
    this situation.  This isn't needed for pack expansions (as the
    accompanying comment points out), and it doesn't seem strictly necessary
    for constexpr if either, but for requires-expressions delaying even
    dependent substitution is important for ensuring we don't evaluate
    requirements out of order.

    It turns out we also need to make a copy of the arguments when capturing
    them so that coerce_template_parms doesn't later add to them and form an
    unexpected cycle (REQUIRES_EXPR_EXTRA_ARGS (t) would indirectly point to
t).
    We also need to make tsubst_template_args handle missing template
    arguments, since the arguments we capture from coerce_template_parms
    and are incomplete at that point.

            PR c++/101181

    gcc/cp/ChangeLog:

            * constraint.cc (tsubst_requires_expr): Pass complain/in_decl to
            add_extra_args.
            * cp-tree.h (add_extra_args): Add complain/in_decl parameters.
            * pt.c (build_extra_args): Make a copy of args.
            (add_extra_args): Add complain/in_decl parameters.  Enable the
            code for handling the case where the extra arguments are
            dependent.
            (tsubst_pack_expansion): Pass complain/in_decl to
            add_extra_args.
            (tsubst_template_args): Handle missing template arguments.
            (tsubst_expr) <case IF_STMT>: Pass complain/in_decl to
            add_extra_args.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-requires26.C: New test.
            * g++.dg/cpp2a/lambda-uneval16.C: New test.

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

* [Bug c++/101181] [11/12 Regression] ICE when using an alias template
  2021-06-23 18:02 [Bug c++/101181] New: ICE when using an alias template webrown.cpp at gmail dot com
                   ` (2 preceding siblings ...)
  2021-07-09 14:22 ` cvs-commit at gcc dot gnu.org
@ 2021-07-13 14:03 ` cvs-commit at gcc dot gnu.org
  2021-07-13 14:10 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-07-13 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:63566075309907ca807c1c6cef57bf19f4602825

commit r11-8734-g63566075309907ca807c1c6cef57bf19f4602825
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jul 9 10:20:25 2021 -0400

    c++: requires-expr with dependent extra args [PR101181]

    Here we're crashing ultimately because the mechanism for delaying
    substitution into a requires-expression (and constexpr if and pack
    expansions) doesn't expect to see dependent args.  But we end up
    capturing dependent args here during substitution into the default
    template argument as part of coerce_template_parms for the dependent
    specialization p<T>.

    This patch enables the commented out code in add_extra_args for handling
    this situation.  This isn't needed for pack expansions (as the
    accompanying comment points out), and it doesn't seem strictly necessary
    for constexpr if either, but for requires-expressions delaying even
    dependent substitution is important for ensuring we don't evaluate
    requirements out of order.

    It turns out we also need to make a copy of the arguments when capturing
    them so that coerce_template_parms doesn't later add to them and form an
    unexpected cycle (REQUIRES_EXPR_EXTRA_ARGS (t) would indirectly point to
t).
    We also need to make tsubst_template_args handle missing template
    arguments, since the arguments we capture from coerce_template_parms
    and are incomplete at that point.

            PR c++/101181

    gcc/cp/ChangeLog:

            * constraint.cc (tsubst_requires_expr): Pass complain/in_decl to
            add_extra_args.
            * cp-tree.h (add_extra_args): Add complain/in_decl parameters.
            * pt.c (build_extra_args): Make a copy of args.
            (add_extra_args): Add complain/in_decl parameters.  Enable the
            code for handling the case where the extra arguments are
            dependent.
            (tsubst_pack_expansion): Pass complain/in_decl to
            add_extra_args.
            (tsubst_template_args): Handle missing template arguments.
            (tsubst_expr) <case IF_STMT>: Pass complain/in_decl to
            add_extra_args.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/concepts-requires26.C: New test.
            * g++.dg/cpp2a/lambda-uneval16.C: New test.

    (cherry picked from commit 2c699fd29829cd6115f78238dab7cab74f0a5009)

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

* [Bug c++/101181] [11/12 Regression] ICE when using an alias template
  2021-06-23 18:02 [Bug c++/101181] New: ICE when using an alias template webrown.cpp at gmail dot com
                   ` (3 preceding siblings ...)
  2021-07-13 14:03 ` cvs-commit at gcc dot gnu.org
@ 2021-07-13 14:10 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-07-13 14:10 UTC (permalink / raw)
  To: gcc-bugs

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

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 11.2/12

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

end of thread, other threads:[~2021-07-13 14:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 18:02 [Bug c++/101181] New: ICE when using an alias template webrown.cpp at gmail dot com
2021-06-30 19:25 ` [Bug c++/101181] [11/12 Regression] " mpolacek at gcc dot gnu.org
2021-07-08  0:10 ` ppalka at gcc dot gnu.org
2021-07-09 14:22 ` cvs-commit at gcc dot gnu.org
2021-07-13 14:03 ` cvs-commit at gcc dot gnu.org
2021-07-13 14:10 ` 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).