public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95735] New: ICE on invalid non-type template argument
@ 2020-06-18  6:09 johelegp at gmail dot com
  2020-06-18  7:40 ` [Bug c++/95735] " marxin at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: johelegp at gmail dot com @ 2020-06-18  6:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95735
           Summary: ICE on invalid non-type template argument
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/v7iLPn.
```C++
template <auto F>
    requires requires { F(); }
bool v{};

void f() {
    int x;
    static_assert(v<throw>);
}
```
<source>: In function 'void f()':
<source>:7:19: error: parse error in template argument list
    7 |     static_assert(v<throw>);
      |                   ^~~~~~~~
<source>:7:19: error: template argument 1 is invalid
<source>:7: confused by earlier errors, bailing out
Compiler returned: 1

Less silly example: https://godbolt.org/z/-bWfJ4.
```C++
template <auto F>
    requires requires { F(); }
bool v{};

void f() {
    int x;
    static_assert(v<[&] { x++; }>);
}
```
<source>: In function 'void f()':
<source>:7:19: error: '<lambda closure object>f()::<lambda()>{x}' is not a
constant expression
    7 |     static_assert(v<[&] { x++; }>);
      |                   ^~~~~~~~~~~~~~~
<source>:7: confused by earlier errors, bailing out
Compiler returned: 1

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

* [Bug c++/95735] ICE on invalid non-type template argument
  2020-06-18  6:09 [Bug c++/95735] New: ICE on invalid non-type template argument johelegp at gmail dot com
@ 2020-06-18  7:40 ` marxin at gcc dot gnu.org
  2020-06-18 13:33 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-06-18  7:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2020-06-18
     Ever confirmed|0                           |1
                 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> ---
Started to ICE with r10-3735-gcb57504a55015891.

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

* [Bug c++/95735] ICE on invalid non-type template argument
  2020-06-18  6:09 [Bug c++/95735] New: ICE on invalid non-type template argument johelegp at gmail dot com
  2020-06-18  7:40 ` [Bug c++/95735] " marxin at gcc dot gnu.org
@ 2020-06-18 13:33 ` mpolacek at gcc dot gnu.org
  2020-06-18 15:11 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-18 13:33 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
The second test ICEs with gcc 6 too.

Patch:
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10154,6 +10154,8 @@ finish_template_variable (tree var, tsubst_flags_t
complain)
   arglist = coerce_innermost_template_parms (parms, arglist, templ, complain,
                         /*req_all*/true,
                         /*use_default*/true);
+  if (arglist == error_mark_node)
+    return error_mark_node;

   if (flag_concepts && !constraints_satisfied_p (templ, arglist))
     {

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

* [Bug c++/95735] ICE on invalid non-type template argument
  2020-06-18  6:09 [Bug c++/95735] New: ICE on invalid non-type template argument johelegp at gmail dot com
  2020-06-18  7:40 ` [Bug c++/95735] " marxin at gcc dot gnu.org
  2020-06-18 13:33 ` mpolacek at gcc dot gnu.org
@ 2020-06-18 15:11 ` mpolacek at gcc dot gnu.org
  2020-06-18 15:51 ` cvs-commit at gcc dot gnu.org
  2020-06-18 15:52 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-18 15:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Posted.

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

* [Bug c++/95735] ICE on invalid non-type template argument
  2020-06-18  6:09 [Bug c++/95735] New: ICE on invalid non-type template argument johelegp at gmail dot com
                   ` (2 preceding siblings ...)
  2020-06-18 15:11 ` mpolacek at gcc dot gnu.org
@ 2020-06-18 15:51 ` cvs-commit at gcc dot gnu.org
  2020-06-18 15:52 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-18 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:5421fae8b17c7401f3a4ac5b9f414a47f7bda379

commit r11-1516-g5421fae8b17c7401f3a4ac5b9f414a47f7bda379
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Jun 18 09:38:42 2020 -0400

    c++: ICE in requires-expressions with invalid args [PR95735]

    This ICE-on-invalid goes back to GCC 6.  In finish_template_variable,
    if coerce_innermost_template_parms returns error_mark_node, we pass
    it down to constraints_satisfied_p and that error_mark_node flows
    down to various satisfy_* functions and then to various tsubst_*
    functions, where we crash.  diagnose_constraints also doesn't cope
    with error arglist, so I think we should just return as in the
    patch below.

    gcc/cp/ChangeLog:

            PR c++/95735
            * pt.c (finish_template_variable): Return if
            coerce_innermost_template_parms return error_mark_node.

    gcc/testsuite/ChangeLog:

            PR c++/95735
            * g++.dg/cpp2a/concepts-err2.C: New test.

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

* [Bug c++/95735] ICE on invalid non-type template argument
  2020-06-18  6:09 [Bug c++/95735] New: ICE on invalid non-type template argument johelegp at gmail dot com
                   ` (3 preceding siblings ...)
  2020-06-18 15:51 ` cvs-commit at gcc dot gnu.org
@ 2020-06-18 15:52 ` mpolacek at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-06-18 15:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2020-06-18 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18  6:09 [Bug c++/95735] New: ICE on invalid non-type template argument johelegp at gmail dot com
2020-06-18  7:40 ` [Bug c++/95735] " marxin at gcc dot gnu.org
2020-06-18 13:33 ` mpolacek at gcc dot gnu.org
2020-06-18 15:11 ` mpolacek at gcc dot gnu.org
2020-06-18 15:51 ` cvs-commit at gcc dot gnu.org
2020-06-18 15:52 ` mpolacek 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).