public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization
@ 2021-09-30 16:09 bob.steagall.cpp at gmail dot com
  2021-09-30 19:16 ` [Bug c++/102547] " ppalka at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: bob.steagall.cpp at gmail dot com @ 2021-09-30 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102547
           Summary: g++ 11. ICE with NTTPs and partial specialization
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bob.steagall.cpp at gmail dot com
  Target Milestone: ---

The following C++ source code:

---------------------------------------------------------------------------

template<int... VALS>
struct vals {};


template<class V, class A>    
struct vals_client {};

template<int V0, int V1, typename A>
struct vals_client<vals<V0, V1>, A> {};

template<int V0, int V1>
struct vals_client<vals<V0, V1>, void> {};


void testfn()
{
    vals_client<vals<1, 2>, int>   ci;  //- OK
    vals_client<vals<1, 2>, void>  cv;  //- "sorry, unimplemented..., ICE" 
}

---------------------------------------------------------------------------

When compiled with gcc 11.X generates this error:


nttp_test.cpp: In function 'void testfn()':
nttp_test.cpp:18:36: sorry, unimplemented: unexpected AST of kind
nontype_argument_pack
   18 |     vals_client<vals<1, 2>, void>  cv;  //- "sorry, unimplemented..."
      |                                    ^~
nttp_test.cpp:18: confused by earlier errors, bailing out

---------------------------------------------------------------------------

When compiled with gcc trunk on godbolt.org, it elicits an ICE:

<source>: In function 'void testfn()':
<source>:23:36: sorry, unimplemented: unexpected AST of kind
nontype_argument_pack
   23 |     vals_client<vals<1, 2>, void>  cv;  //- "sorry, unimplemented...,
ICE"
      |                                    ^~
<source>:23:36: internal compiler error: in potential_constant_expression_1, at
cp/constexpr.c:9051
0x1fe73f9 internal_error(char const*, ...)
        ???:0
0x7d40a7 fancy_abort(char const*, int, char const*)
        ???:0
0x8475ff potential_constant_expression(tree_node*)
        ???:0
0xa21bd7 instantiation_dependent_expression_p(tree_node*)
        ???:0
0xa21c46 uses_template_parms(tree_node*)
        ???:0
0xa72888 most_specialized_partial_spec(tree_node*, int)
        ???:0
0xa7f834 instantiate_class_template(tree_node*)
        ???:0
0x89e107 start_decl_1(tree_node*, bool)
        ???:0
0x8c552f start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
        ???:0
0xa08395 c_parse_file()
        ???:0
0xb8f562 c_common_parse_file()
        ???:0
Please submit a full bug report, ...

---------------------------------------------------------------------------

Testing with various version on godbolt.org reveals that the ICE does not 
occur with 10.X, 9.X, 8.X, or 7.X  (that's as far back as I went).

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

* [Bug c++/102547] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
@ 2021-09-30 19:16 ` ppalka at gcc dot gnu.org
  2021-09-30 19:39 ` ppalka at gcc dot gnu.org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-09-30 19:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2021-09-30
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/102547] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
  2021-09-30 19:16 ` [Bug c++/102547] " ppalka at gcc dot gnu.org
@ 2021-09-30 19:39 ` ppalka at gcc dot gnu.org
  2021-09-30 19:41 ` [Bug c++/102547] [11/12 Regression] " ppalka at gcc dot gnu.org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-09-30 19:39 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/102547] [11/12 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
  2021-09-30 19:16 ` [Bug c++/102547] " ppalka at gcc dot gnu.org
  2021-09-30 19:39 ` ppalka at gcc dot gnu.org
@ 2021-09-30 19:41 ` ppalka at gcc dot gnu.org
  2021-09-30 19:58 ` ppalka at gcc dot gnu.org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-09-30 19:41 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|                            |10.3.0
                 CC|                            |mpolacek at gcc dot gnu.org
            Summary|g++ 11. ICE with NTTPs and  |[11/12 Regression] g++ 11.
                   |partial specialization      |ICE with NTTPs and partial
                   |                            |specialization
           Keywords|                            |rejects-valid
      Known to fail|                            |11.2.0, 12.0
   Target Milestone|---                         |11.3

--- Comment #2 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r11-4671.

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

* [Bug c++/102547] [11/12 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (2 preceding siblings ...)
  2021-09-30 19:41 ` [Bug c++/102547] [11/12 Regression] " ppalka at gcc dot gnu.org
@ 2021-09-30 19:58 ` ppalka at gcc dot gnu.org
  2021-09-30 21:35 ` bob.steagall.cpp at gmail dot com
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-09-30 19:58 UTC (permalink / raw)
  To: gcc-bugs

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

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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
I think I have a potential fix -- replace the problematic call to
uses_template_parms with dependent_template_arg_p:

--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -23587,7 +23587,7 @@ unify (tree tparms, tree targs, tree parm, tree arg,
int strict,
      even if ARG == PARM, since we won't record unifications for the
      template parameters.  We might need them if we're trying to
      figure out which of two things is more specialized.  */
-  if (arg == parm && !uses_template_parms (parm))
+  if (arg == parm && !dependent_template_arg_p (parm))
     return unify_success (explain_p);

   /* Handle init lists early, so the rest of the function can assume

So mine I suppose.

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

* [Bug c++/102547] [11/12 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (3 preceding siblings ...)
  2021-09-30 19:58 ` ppalka at gcc dot gnu.org
@ 2021-09-30 21:35 ` bob.steagall.cpp at gmail dot com
  2021-10-01  6:31 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bob.steagall.cpp at gmail dot com @ 2021-09-30 21:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Bob Steagall <bob.steagall.cpp at gmail dot com> ---
I have applied this tentative change to line 23436 of gcc/cp/pt.c from the
gcc-11.2.0 source tarball, and can confirm that the test case compiles for me.

The code I was working on also compiles, links, and appears to run correctly.

I don't know if this is the final fix, but it is progress.

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

* [Bug c++/102547] [11/12 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (4 preceding siblings ...)
  2021-09-30 21:35 ` bob.steagall.cpp at gmail dot com
@ 2021-10-01  6:31 ` rguenth at gcc dot gnu.org
  2021-10-05 19:36 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-10-01  6:31 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug c++/102547] [11/12 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (5 preceding siblings ...)
  2021-10-01  6:31 ` rguenth at gcc dot gnu.org
@ 2021-10-05 19:36 ` cvs-commit at gcc dot gnu.org
  2021-10-05 19:43 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-05 19:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 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:d4c470c376b4cb82c9a0b7e8a4b88c44d5e4289d

commit r12-4196-gd4c470c376b4cb82c9a0b7e8a4b88c44d5e4289d
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Oct 5 15:35:21 2021 -0400

    c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]

    Here during partial ordering of the two partial specializations we end
    up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly
    thereafter because uses_template_parms(parms) calls potential_const_expr
    which doesn't handle NONTYPE_ARGUMENT_PACK.

    This patch fixes this by extending potential_constant_expression to handle
    NONTYPE_ARGUMENT_PACK appropriately.

            PR c++/102547

    gcc/cp/ChangeLog:

            * constexpr.c (potential_constant_expression_1): Handle
            NONTYPE_ARGUMENT_PACK.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/variadic-partial2.C: New test.
            * g++.dg/cpp0x/variadic-partial2a.C: New test.

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

* [Bug c++/102547] [11/12 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (6 preceding siblings ...)
  2021-10-05 19:36 ` cvs-commit at gcc dot gnu.org
@ 2021-10-05 19:43 ` ppalka at gcc dot gnu.org
  2021-10-05 19:44 ` [Bug c++/102547] [11 " ppalka at gcc dot gnu.org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-05 19:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
(In reply to Bob Steagall from comment #4)
> I have applied this tentative change to line 23436 of gcc/cp/pt.c from the
> gcc-11.2.0 source tarball, and can confirm that the test case compiles for
> me.
> 
> The code I was working on also compiles, links, and appears to run correctly.
> 
> I don't know if this is the final fix, but it is progress.

Excellent, thanks for testing.  The final fix is different but should have the
same effect.

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

* [Bug c++/102547] [11 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (7 preceding siblings ...)
  2021-10-05 19:43 ` ppalka at gcc dot gnu.org
@ 2021-10-05 19:44 ` ppalka at gcc dot gnu.org
  2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-05 19:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12 Regression] g++ 11.  |[11 Regression] g++ 11. ICE
                   |ICE with NTTPs and partial  |with NTTPs and partial
                   |specialization              |specialization

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12 so far.

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

* [Bug c++/102547] [11 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (8 preceding siblings ...)
  2021-10-05 19:44 ` [Bug c++/102547] [11 " ppalka at gcc dot gnu.org
@ 2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org
  2021-10-06 14:21 ` ppalka at gcc dot gnu.org
  2021-10-29 19:43 ` ppalka at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-06 14:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 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:1aef951f1aa0b50a8da12f6fe6e80f3fdaa4d98e

commit r11-9086-g1aef951f1aa0b50a8da12f6fe6e80f3fdaa4d98e
Author: Patrick Palka <ppalka@redhat.com>
Date:   Tue Oct 5 15:35:21 2021 -0400

    c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547]

    Here during partial ordering of the two partial specializations we end
    up in unify with parm=arg=NONTYPE_ARGUMENT_PACK<V0, V1>, and crash shortly
    thereafter because uses_template_parms(parms) calls potential_const_expr
    which doesn't handle NONTYPE_ARGUMENT_PACK.

    This patch fixes this by extending potential_constant_expression to handle
    NONTYPE_ARGUMENT_PACK appropriately.

            PR c++/102547

    gcc/cp/ChangeLog:

            * constexpr.c (potential_constant_expression_1): Handle
            NONTYPE_ARGUMENT_PACK.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/variadic-partial2.C: New test.
            * g++.dg/cpp0x/variadic-partial2a.C: New test.

    (cherry picked from commit d4c470c376b4cb82c9a0b7e8a4b88c44d5e4289d)

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

* [Bug c++/102547] [11 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (9 preceding siblings ...)
  2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org
@ 2021-10-06 14:21 ` ppalka at gcc dot gnu.org
  2021-10-29 19:43 ` ppalka at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-06 14:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #9 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 11.3 and 12.

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

* [Bug c++/102547] [11 Regression] g++ 11. ICE with NTTPs and partial specialization
  2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
                   ` (10 preceding siblings ...)
  2021-10-06 14:21 ` ppalka at gcc dot gnu.org
@ 2021-10-29 19:43 ` ppalka at gcc dot gnu.org
  11 siblings, 0 replies; 13+ messages in thread
From: ppalka at gcc dot gnu.org @ 2021-10-29 19:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |cantonios at google dot com

--- Comment #10 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 102999 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2021-10-29 19:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 16:09 [Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization bob.steagall.cpp at gmail dot com
2021-09-30 19:16 ` [Bug c++/102547] " ppalka at gcc dot gnu.org
2021-09-30 19:39 ` ppalka at gcc dot gnu.org
2021-09-30 19:41 ` [Bug c++/102547] [11/12 Regression] " ppalka at gcc dot gnu.org
2021-09-30 19:58 ` ppalka at gcc dot gnu.org
2021-09-30 21:35 ` bob.steagall.cpp at gmail dot com
2021-10-01  6:31 ` rguenth at gcc dot gnu.org
2021-10-05 19:36 ` cvs-commit at gcc dot gnu.org
2021-10-05 19:43 ` ppalka at gcc dot gnu.org
2021-10-05 19:44 ` [Bug c++/102547] [11 " ppalka at gcc dot gnu.org
2021-10-06 14:15 ` cvs-commit at gcc dot gnu.org
2021-10-06 14:21 ` ppalka at gcc dot gnu.org
2021-10-29 19:43 ` 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).