public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96960] New: ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement
@ 2020-09-07 18:11 hstong at ca dot ibm.com
  2020-09-11 13:31 ` [Bug c++/96960] " mpolacek at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hstong at ca dot ibm.com @ 2020-09-07 18:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96960
           Summary: ICE in tsubst_copy_and_build, at cp/pt.c:20531 from
                    lambda in return-type-requirement
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hstong at ca dot ibm.com
  Target Milestone: ---

The following program ICEs with GCC.

The ICE appears to related to the lambda expression in the
return-type-requirement

### SOURCE (<stdin>):
template <typename, typename> concept C0 = true;

template <typename T>
concept C =
requires(T t) {
  { 42 } -> C0<char [([] { return 42; }())]>;
};

static_assert(C<int>);

### COMPILER INVOCATION:
g++ -fsyntax-only -std=c++20 -xc++ -


### ACTUAL OUTPUT:
<stdin>:6:23: internal compiler error: in tsubst_copy_and_build, at
cp/pt.c:20531
0x5c9d7a tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:20531
0x72c6bd tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:19873
0x72c6bd tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:19873
0x73e1e4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:19266
0x73e1e4 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18879
0x72f59b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:17933
0x72f59b tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../source/gcc/cp/pt.c:15349
0x72f1e3 tsubst(tree_node*, tree_node*, int, tree_node*)
        ../../source/gcc/cp/pt.c:15792
0x742ec2 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ../../source/gcc/cp/pt.c:13215
0x72c209 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:19333
0x73e1e4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:19266
0x73e1e4 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18879
0x647cf7 tsubst_constraint(tree_node*, tree_node*, int, tree_node*)
        ../../source/gcc/cp/constraint.cc:2402
0x647cf7 type_deducible_p
        ../../source/gcc/cp/constraint.cc:1932
0x64c23a tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
        ../../source/gcc/cp/constraint.cc:2013
0x72c55e tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:20566
0x73e1e4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../source/gcc/cp/pt.c:19266
0x73e1e4 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../source/gcc/cp/pt.c:18879
0x64ba61 satisfy_constraint_r
        ../../source/gcc/cp/constraint.cc:2610
0x64bee8 satisfy_constraint
        ../../source/gcc/cp/constraint.cc:2692
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.


### EXPECTED OUTPUT:
(clean compile)


### COMPILER VERSION INFO (g++ -v):
Using built-in specs.
COLLECT_GCC=/opt/wandbox/gcc-head/bin/g++
COLLECT_LTO_WRAPPER=/opt/wandbox/gcc-head/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../source/configure --prefix=/opt/wandbox/gcc-head
--enable-languages=c,c++ --disable-multilib --without-ppl --without-cloog-ppl
--enable-checking=release --disable-nls --enable-lto
LDFLAGS=-Wl,-rpath,/opt/wandbox/gcc-head/lib,-rpath,/opt/wandbox/gcc-head/lib64,-rpath,/opt/wandbox/gcc-head/lib32
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20200906 (experimental) (GCC)

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

* [Bug c++/96960] ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement
  2020-09-07 18:11 [Bug c++/96960] New: ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement hstong at ca dot ibm.com
@ 2020-09-11 13:31 ` mpolacek at gcc dot gnu.org
  2020-12-03 19:18 ` [Bug c++/96960] [C++20] " jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-09-11 13:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-09-11
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.  10 ICEs too.

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

* [Bug c++/96960] [C++20] ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement
  2020-09-07 18:11 [Bug c++/96960] New: ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement hstong at ca dot ibm.com
  2020-09-11 13:31 ` [Bug c++/96960] " mpolacek at gcc dot gnu.org
@ 2020-12-03 19:18 ` jason at gcc dot gnu.org
  2021-02-16 15:28 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2020-12-03 19:18 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
            Summary|ICE in                      |[C++20] ICE in
                   |tsubst_copy_and_build, at   |tsubst_copy_and_build, at
                   |cp/pt.c:20531 from lambda   |cp/pt.c:20531 from lambda
                   |in return-type-requirement  |in return-type-requirement

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
This has to do with type_deducible_p's use of tf_partial.  That function is
left over from the days before P1084; we still kind of treat return type
requirements as deduction rather than simply checking the constraint.  Though
other places where we do need to do deduction work properly:

C0<char [([] { return 42; }())]> auto x = 42;

int f(C0<char [([] { return 42; }())]> auto x);
int y = f(42);

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

* [Bug c++/96960] [C++20] ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement
  2020-09-07 18:11 [Bug c++/96960] New: ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement hstong at ca dot ibm.com
  2020-09-11 13:31 ` [Bug c++/96960] " mpolacek at gcc dot gnu.org
  2020-12-03 19:18 ` [Bug c++/96960] [C++20] " jason at gcc dot gnu.org
@ 2021-02-16 15:28 ` ppalka at gcc dot gnu.org
  2021-03-02 12:50 ` cvs-commit at gcc dot gnu.org
  2021-03-03 23:02 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-02-16 15:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Looks like the (not yet committed) rework of placeholder type constraint
satisfaction at
https://gcc.gnu.org/pipermail/gcc-patches/2021-February/565205.html fixes this.

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

* [Bug c++/96960] [C++20] ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement
  2020-09-07 18:11 [Bug c++/96960] New: ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement hstong at ca dot ibm.com
                   ` (2 preceding siblings ...)
  2021-02-16 15:28 ` ppalka at gcc dot gnu.org
@ 2021-03-02 12:50 ` cvs-commit at gcc dot gnu.org
  2021-03-03 23:02 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-02 12:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 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:e52f8ec25c0e58ebd083e8370e2fbc8af4120d87

commit r11-7454-ge52f8ec25c0e58ebd083e8370e2fbc8af4120d87
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Mar 2 07:49:29 2021 -0500

    c++: Fix satisfaction of placeholder type constraints [PR96443]

    This fixes the way we check satisfaction of constraints on placeholder
    types in various deduction contexts, and in particular when the
    constraint is dependent.

    Firstly, when evaluating the return type requirement of a compound
    requirement, we currently substitute the outer template arguments into
    the constraint before checking satisfaction. But we should instead be
    passing in the complete set of template arguments to satisfaction and
    not do a prior separate substitution.  Our current approach leads to us
    incorrectly rejecting the testcase concepts-return-req2.C below.

    Secondly, when checking the constraints on a placeholder variable or
    return type, we don't consider the template arguments of the enclosing
    context at all.  This leads to bogus errors during satisfaction when the
    constraint is dependent as in the testcase concepts-placeholder3.C
    below.

    In order to fix these two issues, we need to be able to normalize the
    constraints on a placeholder 'auto' on demand, which in turn requires us
    to know the template parameters that were in scope where the 'auto' was
    introduced.  This information currently doesn't seem to be easily available
    when we need it, so this patch turns PLACEHOLDER_TYPE_CONSTRAINTS into a
    TREE_LIST whose TREE_PURPOSE additionally holds the value of
    current_template_parms whence a constrained 'auto' was formed.

    This patch also removes some seemingly wrong handling of placeholder
    type arguments from tsubst_parameter_mapping.  The code doesn't trigger
    with the example used in the comments, because type_uses_auto doesn't
    look inside non-deduced contexts such as the operand of decltype.  And
    the call to do_auto_deduction seems confused because if 'arg' is a type,
    then so is 'parm', and therefore 'init' too is a type, but
    do_auto_deduction expects it to be an expression.  Before this patch,
    this code was dead (as far as our testsuite can tell), but now it breaks
    other parts of this patch, so let's remove it.

    gcc/cp/ChangeLog:

            PR c++/96443
            PR c++/96960
            * constraint.cc (type_deducible_p): Don't substitute into the
            constraints, and instead just pass 'args' to do_auto_deduction
            as the outer template arguments.
            (tsubst_parameter_mapping): Remove confused code for handling
            placeholder type arguments.
            (normalize_placeholder_type_constraint): Define.
            (satisfy_constraint_expression): Use it to handle placeholder
            'auto' types.
            * cp-tree.h (PLACEHOLDER_TYPE_CONSTRAINTS_INFO): Define.
            (PLACEHOLDER_TYPE_CONSTRAINTS): Redefine in terms of the above.
            * pt.c (tsubst) <case TEMPLATE_TYPE_PARM>: Use
            PLACEHOLDER_TYPE_CONSTRAINTS_INFO instead.
            (make_constrained_placeholder_type): Set
            PLACEHOLDER_TYPE_CONSTRAINTS_INFO instead.
            (do_auto_deduction): Clarify comments about the outer_targs
            parameter.  Rework satisfaction of a placeholder type constraint
            to pass in the complete set of template arguments directly to
            constraints_satisfied_p.
            (splice_late_return_type): Use PLACEHOLDER_TYPE_CONSTRAINTS_INFO
            instead.  Also rebuild the the constraint info on the new auto.

    gcc/testsuite/ChangeLog:

            PR c++/96443
            PR c++/96960
            * g++.dg/concepts/abbrev9.C: New test.
            * g++.dg/cpp2a/concepts-lambda15.C: New test.
            * g++.dg/cpp2a/concepts-placeholder3.C: New test.
            * g++.dg/cpp2a/concepts-return-req2.C: New test.
            * g++.dg/cpp2a/concepts-ts1.C: Add dg-bogus directive to the
            call to f15 that we expect to accept.

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

* [Bug c++/96960] [C++20] ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement
  2020-09-07 18:11 [Bug c++/96960] New: ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement hstong at ca dot ibm.com
                   ` (3 preceding siblings ...)
  2021-03-02 12:50 ` cvs-commit at gcc dot gnu.org
@ 2021-03-03 23:02 ` ppalka at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-03-03 23:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11.

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

end of thread, other threads:[~2021-03-03 23:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 18:11 [Bug c++/96960] New: ICE in tsubst_copy_and_build, at cp/pt.c:20531 from lambda in return-type-requirement hstong at ca dot ibm.com
2020-09-11 13:31 ` [Bug c++/96960] " mpolacek at gcc dot gnu.org
2020-12-03 19:18 ` [Bug c++/96960] [C++20] " jason at gcc dot gnu.org
2021-02-16 15:28 ` ppalka at gcc dot gnu.org
2021-03-02 12:50 ` cvs-commit at gcc dot gnu.org
2021-03-03 23:02 ` 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).