public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda
@ 2020-03-10 19:00 bisqwit at iki dot fi
  2020-03-11  9:36 ` [Bug c++/94128] " marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: bisqwit at iki dot fi @ 2020-03-10 19:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94128
           Summary: ICE on C++20 "requires requires" with lambda
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bisqwit at iki dot fi
  Target Milestone: ---

For this code:

    void test(auto param)
    requires requires{ { [](auto p){return p;}(param) }; };

    void test2() { test(1); }

On this compiler:

    g++-10 (Debian 10-20200222-1) 10.0.1 20200222 (experimental) [master
revision 01af7e0a0c2:487fe13f218:e99b18cf7101f205bfdd9f0f29ed51caaec52779]

Compiling with this commandline:

    g++-10 -v tmp.cc -std=c++20

We get:

Using built-in specs.
COLLECT_GCC=g++-10
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10-20200222-1'
--with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs
--enable-languages=c,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-offload-targets=nvptx-none,amdgcn-amdhsa,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.0.1 20200222 (experimental) [master revision
01af7e0a0c2:487fe13f218:e99b18cf7101f205bfdd9f0f29ed51caaec52779] (Debian
10-20200222-1) 
COLLECT_GCC_OPTIONS='-v' '-std=c++2a' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/10/cc1plus -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE tmp.cc -quiet -dumpbase tmp.cc -mtune=generic
-march=x86-64 -auxbase tmp -std=c++2a -version -fasynchronous-unwind-tables -o
/tmp/cc8CWcEJ.s
GNU C++17 (Debian 10-20200222-1) version 10.0.1 20200222 (experimental) [master
revision 01af7e0a0c2:487fe13f218:e99b18cf7101f205bfdd9f0f29ed51caaec52779]
(x86_64-linux-gnu)
        compiled by GNU C version 10.0.1 20200222 (experimental) [master
revision 01af7e0a0c2:487fe13f218:e99b18cf7101f205bfdd9f0f29ed51caaec52779], GMP
version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22-GMP

warning: GMP header version 6.2.0 differs from library version 6.1.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/10"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/10
 /usr/include/x86_64-linux-gnu/c++/10
 /usr/include/c++/10/backward
 /usr/lib/gcc/x86_64-linux-gnu/10/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/10/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++17 (Debian 10-20200222-1) version 10.0.1 20200222 (experimental) [master
revision 01af7e0a0c2:487fe13f218:e99b18cf7101f205bfdd9f0f29ed51caaec52779]
(x86_64-linux-gnu)
        compiled by GNU C version 10.0.1 20200222 (experimental) [master
revision 01af7e0a0c2:487fe13f218:e99b18cf7101f205bfdd9f0f29ed51caaec52779], GMP
version 6.2.0, MPFR version 4.0.2, MPC version 1.1.0, isl version isl-0.22-GMP

warning: GMP header version 6.2.0 differs from library version 6.1.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: f533434f622c23e753fbd5b6135ebdd3
tmp.cc: In instantiation of ‘void test(auto:1) requires
requires{{(<lambda>)(test::param)};} [with auto:1 = int]’:
tmp.cc:3:22:   required from here
tmp.cc:2:26: internal compiler error: Segmentation fault
    2 |     requires requires{ { [](auto p){return p;}(param) }; };
      |                          ^~~~~~~~~~~~~~~~~~~~~
0xc248ef crash_signal
        ../../src/gcc/toplev.c:328
0x7fb53dd2d0ff ???
       
/build/glibc-kSJANG/glibc-2.29/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x733be8 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        ../../src/gcc/cp/pt.c:13090
0x738602 tsubst_function_decl
        ../../src/gcc/cp/pt.c:13501
0x738e38 tsubst_template_decl
        ../../src/gcc/cp/pt.c:13894
0x72a95e tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
        ../../src/gcc/cp/pt.c:18862
0x72d085 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../src/gcc/cp/pt.c:20304
0x72be2c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../src/gcc/cp/pt.c:18962
0x72be2c tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../src/gcc/cp/pt.c:19559
0x7250a4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../src/gcc/cp/pt.c:18962
0x7250a4 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../src/gcc/cp/pt.c:18597
0x648a39 tsubst_requires_expr(tree_node*, tree_node*, int, tree_node*)
        ../../src/gcc/cp/constraint.cc:1866
0x72c7f4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../src/gcc/cp/pt.c:20336
0x7250a4 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        ../../src/gcc/cp/pt.c:18962
0x7250a4 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        ../../src/gcc/cp/pt.c:18597
0x648082 satisfy_constraint_r
        ../../src/gcc/cp/constraint.cc:2523
0x6487e8 satisfy_constraint
        ../../src/gcc/cp/constraint.cc:2599
0x649184 satisfy_declaration_constraints
        ../../src/gcc/cp/constraint.cc:2617
0x649c68 constraint_satisfaction_value
        ../../src/gcc/cp/constraint.cc:2733
0x649c68 constraints_satisfied_p(tree_node*)
        ../../src/gcc/cp/constraint.cc:2754
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-10/README.Bugs> for instructions.

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

* [Bug c++/94128] ICE on C++20 "requires requires" with lambda
  2020-03-10 19:00 [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda bisqwit at iki dot fi
@ 2020-03-11  9:36 ` marxin at gcc dot gnu.org
  2020-03-11  9:42 ` bisqwit at iki dot fi
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-03-11  9:36 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|unknown                     |10.0
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-03-11
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |marxin at gcc dot gnu.org

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Is it really a valid code?
Started to ICE with r10-3735-gcb57504a55015891, before that we rejected the
code:

pr94128.cc:1:11: warning: use of ‘auto’ in parameter declaration only available
with ‘-fconcepts’
    1 | void test(auto param)
      |           ^~~~
pr94128.cc:2:3: error: ‘requires’ only available with ‘-fconcepts’
    2 |   requires requires{ { [](auto p){return p;}(param) }; };
      |   ^~~~~~~~
pr94128.cc:2:12: error: ‘requires’ was not declared in this scope
    2 |   requires requires{ { [](auto p){return p;}(param) }; };
      |            ^~~~~~~~
pr94128.cc: In function ‘void test(auto:1)’:
pr94128.cc:2:52: error: expected ‘;’ before ‘}’ token
    2 |   requires requires{ { [](auto p){return p;}(param) }; };
      |                                                    ^~

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

* [Bug c++/94128] ICE on C++20 "requires requires" with lambda
  2020-03-10 19:00 [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda bisqwit at iki dot fi
  2020-03-11  9:36 ` [Bug c++/94128] " marxin at gcc dot gnu.org
@ 2020-03-11  9:42 ` bisqwit at iki dot fi
  2020-05-28 13:54 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bisqwit at iki dot fi @ 2020-03-11  9:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Joel Yliluoma <bisqwit at iki dot fi> ---
Yes, it is valid.

— The auto parameter is valid since C++20. It is called a “placeholder type”,
which has existed since C++11. C++20 made it valid also in function parameters.

— The “requires” is a valid keyword since C++20. It specifies constraints that
the parameter must match. The double “requires” manifests in certain
situations.

— Until C++20, lambdas were not permitted in unevaluated contexts. Changed in
C++20.

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

* [Bug c++/94128] ICE on C++20 "requires requires" with lambda
  2020-03-10 19:00 [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda bisqwit at iki dot fi
  2020-03-11  9:36 ` [Bug c++/94128] " marxin at gcc dot gnu.org
  2020-03-11  9:42 ` bisqwit at iki dot fi
@ 2020-05-28 13:54 ` ppalka at gcc dot gnu.org
  2020-05-29 13:45 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-05-28 13:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

* [Bug c++/94128] ICE on C++20 "requires requires" with lambda
  2020-03-10 19:00 [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda bisqwit at iki dot fi
                   ` (2 preceding siblings ...)
  2020-05-28 13:54 ` ppalka at gcc dot gnu.org
@ 2020-05-29 13:45 ` cvs-commit at gcc dot gnu.org
  2020-05-30  4:21 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-29 13:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

commit r11-723-g020d86db8896f088435830595640e6fc21bc64ad
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri May 29 09:40:40 2020 -0400

    c++: lambdas inside constraints [PR92652]

    When parsing a constraint-expression, a requires-clause or a
    requires-expression, we temporarily increment processing_template_decl
    so that we always obtain template trees which we could later reduce via
    substitution even when not inside a template.

    But incrementing processing_template_decl when we're already inside a
    template has the unintended side effect of shifting up the template
    parameter levels of a lambda defined inside one of these constructs,
    which leads to confusion later during substitution into the lambda.

    This patch fixes this issue by incrementing processing_template_decl
    during parsing of these constructs only if it is 0.

    Passes 'make check-c++', and also tested by building cmcstl2, does this
    look OK to commit after a full bootstrap/regtest?

    gcc/cp/ChangeLog:

            PR c++/92652
            PR c++/93698
            PR c++/94128
            * parser.c (cp_parser_requires_clause_expression): Temporarily
            increment processing_template_decl only if it is 0.
            (cp_parser_constraint_expression): Likewise.
            (cp_parser_requires_expression): Likewise.

    gcc/testsuite/ChangeLog:

            PR c++/92652
            PR c++/93698
            PR c++/94128
            * g++.dg/cpp2a/concepts-lambda8.C: New test.
            * g++.dg/cpp2a/concepts-lambda9.C: New test.
            * g++.dg/cpp2a/concepts-lambda10.C: New test.

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

* [Bug c++/94128] ICE on C++20 "requires requires" with lambda
  2020-03-10 19:00 [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda bisqwit at iki dot fi
                   ` (3 preceding siblings ...)
  2020-05-29 13:45 ` cvs-commit at gcc dot gnu.org
@ 2020-05-30  4:21 ` cvs-commit at gcc dot gnu.org
  2020-05-30  4:24 ` ppalka at gcc dot gnu.org
  2021-08-08  9:01 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-30  4:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:03c344ad180e094140be514a5e7cbaf95b5dcd2e

commit r10-8214-g03c344ad180e094140be514a5e7cbaf95b5dcd2e
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri May 29 14:17:02 2020 -0400

    c++: lambdas inside constraints [PR92652]

    When parsing a constraint-expression, a requires-clause or a
    requires-expression, we temporarily increment processing_template_decl
    so that we always obtain template trees which we could later reduce via
    substitution even when not inside a template.

    But incrementing processing_template_decl when we're already inside a
    template has the unintended side effect of shifting up the template
    parameter levels of a lambda defined inside one of these constructs,
    which leads to confusion later during substitution into the lambda.

    This patch fixes this issue by incrementing processing_template_decl
    during parsing of these constructs only if it is 0.

    gcc/cp/ChangeLog:

            PR c++/92652
            PR c++/93698
            PR c++/94128
            * parser.c (cp_parser_requires_clause_expression): Temporarily
            increment processing_template_decl only if it is 0.
            (cp_parser_constraint_expression): Likewise.
            (cp_parser_requires_expression): Likewise.

    gcc/testsuite/ChangeLog:

            PR c++/92652
            PR c++/93698
            PR c++/94128
            * g++.dg/cpp2a/concepts-lambda8.C: New test.
            * g++.dg/cpp2a/concepts-lambda9.C: New test.
            * g++.dg/cpp2a/concepts-lambda10.C: New test.

    (cherry picked from commit 020d86db8896f088435830595640e6fc21bc64ad)

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

* [Bug c++/94128] ICE on C++20 "requires requires" with lambda
  2020-03-10 19:00 [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda bisqwit at iki dot fi
                   ` (4 preceding siblings ...)
  2020-05-30  4:21 ` cvs-commit at gcc dot gnu.org
@ 2020-05-30  4:24 ` ppalka at gcc dot gnu.org
  2021-08-08  9:01 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ppalka at gcc dot gnu.org @ 2020-05-30  4:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

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

* [Bug c++/94128] ICE on C++20 "requires requires" with lambda
  2020-03-10 19:00 [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda bisqwit at iki dot fi
                   ` (5 preceding siblings ...)
  2020-05-30  4:24 ` ppalka at gcc dot gnu.org
@ 2021-08-08  9:01 ` pinskia at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-08  9:01 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmusiienko at gmail dot com

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 94333 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2021-08-08  9:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-10 19:00 [Bug c++/94128] New: ICE on C++20 "requires requires" with lambda bisqwit at iki dot fi
2020-03-11  9:36 ` [Bug c++/94128] " marxin at gcc dot gnu.org
2020-03-11  9:42 ` bisqwit at iki dot fi
2020-05-28 13:54 ` ppalka at gcc dot gnu.org
2020-05-29 13:45 ` cvs-commit at gcc dot gnu.org
2020-05-30  4:21 ` cvs-commit at gcc dot gnu.org
2020-05-30  4:24 ` ppalka at gcc dot gnu.org
2021-08-08  9:01 ` pinskia 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).