public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index
@ 2022-05-04 14:48 chfast at gmail dot com
  2022-05-04 14:57 ` [Bug c++/105481] [9/10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: chfast at gmail dot com @ 2022-05-04 14:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105481
           Summary: ICE: unexpected expression of kind template_parm_index
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chfast at gmail dot com
  Target Milestone: ---

I get 

intx_reduced.cpp: In substitution of ‘template<unsigned int N, class T, class>
uint<N> f(const T&) [with unsigned int N = N; T = uint<N>;
<template-parameter-1-3> = <missing>]’:
intx_reduced.cpp:18:31:   required from here
intx_reduced.cpp:13:5: internal compiler error: unexpected expression ‘N’ of
kind template_parm_index
   13 |     typename = typename std::enable_if<std::is_convertible<T,
uint<N>>::value>::type>
      |     ^~~~~~~~


for code:

#include <type_traits>

template <unsigned N>
struct uint
{
   int words_[N];
};

template <unsigned N>
uint<N> f(const uint<N>& y) noexcept;

template <unsigned N, typename T,
    typename = typename std::enable_if<std::is_convertible<T,
uint<N>>::value>::type>
uint<N> f(const T& y) noexcept;

using X = uint<1>;

X (*fp)(X const&) noexcept = &f;


The reduced version (cvise):

template <typename _Tp, _Tp __v> struct integral_constant {
  static constexpr _Tp value = __v;
};
using true_type = integral_constant<bool, true>;
using false_type = integral_constant<bool, false>;
template <bool __v> using __bool_constant = integral_constant<bool, __v>;
template <bool, typename, typename> struct conditional;
template <typename...> struct __or_;
template <typename _B1, typename _B2>
struct __or_<_B1, _B2> : conditional<_B1::value, _B1, _B2>::type {};
template <typename> struct is_const;
template <typename> struct is_array : false_type {};
template <typename _Tp>
struct is_function : __bool_constant<!is_const<_Tp>::value> {};
template <typename> struct is_const : true_type {};
template <typename, typename _To,
          bool = __or_<is_function<_To>, is_array<_To>>::value>
struct __is_convertible_helper {
  template <typename> static true_type __test(int);
  typedef decltype(__test<_To>(0)) type;
};
template <typename _From, typename _To>
struct is_convertible : __is_convertible_helper<_From, _To>::type {};
template <bool, typename _Tp = void> struct enable_if { typedef _Tp type; };
template <typename _Iftrue, typename _Iffalse>
struct conditional<false, _Iftrue, _Iffalse> {
  typedef _Iffalse type;
};
template <unsigned> struct uint;
template <unsigned N> uint<N> f(const uint<N> &);
template <
    unsigned N, typename T,
    typename = typename enable_if<is_convertible<T, uint<N>>::value>::type>
uint<N> f(T);
using X = uint<1>;
X (*fp)(X const &) = f;

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

* [Bug c++/105481] [9/10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
@ 2022-05-04 14:57 ` mpolacek at gcc dot gnu.org
  2022-05-04 15:03 ` mpolacek at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-04 14:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Priority|P3                          |P2
   Target Milestone|---                         |9.5
     Ever confirmed|0                           |1
           Keywords|                            |ice-on-valid-code
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org
   Last reconfirmed|                            |2022-05-04
            Summary|ICE: unexpected expression  |[9/10/11/12/13 Regression]
                   |of kind template_parm_index |ICE: unexpected expression
                   |                            |of kind template_parm_index

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r269826.  GCC 7 and clang++ compile this.

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

* [Bug c++/105481] [9/10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
  2022-05-04 14:57 ` [Bug c++/105481] [9/10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
@ 2022-05-04 15:03 ` mpolacek at gcc dot gnu.org
  2022-05-05 11:57 ` ppalka at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-04 15:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=86918

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #1)
> Started with r269826.  GCC 7 and clang++ compile this.

So not a dup of bug 86918 it seems.

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

* [Bug c++/105481] [9/10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
  2022-05-04 14:57 ` [Bug c++/105481] [9/10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
  2022-05-04 15:03 ` mpolacek at gcc dot gnu.org
@ 2022-05-05 11:57 ` ppalka at gcc dot gnu.org
  2022-05-05 12:29 ` ppalka at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-05 11:57 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
more reduced:

template<unsigned> struct uint;
template<unsigned N> uint<N> f(const uint<N> &);
template<unsigned N, typename T, typename = uint<N>> uint<N> f(T);
using X = uint<1>;
X (*fp)(X const &) = f;

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

* [Bug c++/105481] [9/10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
                   ` (2 preceding siblings ...)
  2022-05-05 11:57 ` ppalka at gcc dot gnu.org
@ 2022-05-05 12:29 ` ppalka at gcc dot gnu.org
  2022-05-05 12:32 ` ppalka at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-05 12:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
During type_unification_real as part of partial ordering, when considering
default template arguments we assume all previously deduced arguments are
non-dependent and therefore default argument instantiation will be
non-dependent.  But I don't think that's true for partial ordering, where we
may end up deducing dependent arguments e.g. deducing N for N in the comment #3
testcase.

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

* [Bug c++/105481] [9/10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
                   ` (3 preceding siblings ...)
  2022-05-05 12:29 ` ppalka at gcc dot gnu.org
@ 2022-05-05 12:32 ` ppalka at gcc dot gnu.org
  2022-05-27  9:48 ` [Bug c++/105481] [10/11/12/13 " rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-05-05 12:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Here's a closely related rejects-valid (rather than ICE-on-valid) testcase,
where the default argument is now T instead of uint<N> (which shouldn't affect
the outcome of partial ordering):

template<unsigned> struct uint;
template<unsigned N> uint<N> f(const uint<N> &);             // #1
template<unsigned N, typename T, typename = T> uint<N> f(T); // #2
using X = uint<1>;
X (*fp)(X const &) = f; // should use #1, instead diagnoses as ambiguous

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

* [Bug c++/105481] [10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
                   ` (4 preceding siblings ...)
  2022-05-05 12:32 ` ppalka at gcc dot gnu.org
@ 2022-05-27  9:48 ` rguenth at gcc dot gnu.org
  2022-06-28 10:49 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:48 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug c++/105481] [10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
                   ` (5 preceding siblings ...)
  2022-05-27  9:48 ` [Bug c++/105481] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:49 ` jakub at gcc dot gnu.org
  2023-03-23 21:50 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:49 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug c++/105481] [10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
                   ` (6 preceding siblings ...)
  2022-06-28 10:49 ` jakub at gcc dot gnu.org
@ 2023-03-23 21:50 ` jason at gcc dot gnu.org
  2023-03-24 16:32 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jason at gcc dot gnu.org @ 2023-03-23 21:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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

* [Bug c++/105481] [10/11/12/13 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
                   ` (7 preceding siblings ...)
  2023-03-23 21:50 ` jason at gcc dot gnu.org
@ 2023-03-24 16:32 ` cvs-commit at gcc dot gnu.org
  2023-04-18 20:46 ` [Bug c++/105481] [10/11/12 " cvs-commit at gcc dot gnu.org
  2023-07-07 10:43 ` [Bug c++/105481] [11 " rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-24 16:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:4e2cdb1ddb5f6ace909358775e94bfe23046ad5a

commit r13-6853-g4e2cdb1ddb5f6ace909358775e94bfe23046ad5a
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 23 18:20:52 2023 -0400

    c++: default template arg, partial ordering [PR105481]

    The default argument code in type_unification_real was assuming that all
    targs we've deduced by that point are non-dependent, but that's not the
case
    for partial ordering.

            PR c++/105481

    gcc/cp/ChangeLog:

            * pt.cc (type_unification_real): Adjust for partial ordering.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/fntmpdefarg-partial1.C: New test.

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

* [Bug c++/105481] [10/11/12 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
                   ` (8 preceding siblings ...)
  2023-03-24 16:32 ` cvs-commit at gcc dot gnu.org
@ 2023-04-18 20:46 ` cvs-commit at gcc dot gnu.org
  2023-07-07 10:43 ` [Bug c++/105481] [11 " rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-18 20:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:ab7c0a44ca9e913af654ae82963565d61d8bb39f

commit r12-9443-gab7c0a44ca9e913af654ae82963565d61d8bb39f
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 23 18:20:52 2023 -0400

    c++: default template arg, partial ordering [PR105481]

    The default argument code in type_unification_real was assuming that all
    targs we've deduced by that point are non-dependent, but that's not the
case
    for partial ordering.

            PR c++/105481

    gcc/cp/ChangeLog:

            * pt.cc (type_unification_real): Adjust for partial ordering.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/fntmpdefarg-partial1.C: New test.

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

* [Bug c++/105481] [11 Regression] ICE: unexpected expression of kind template_parm_index
  2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
                   ` (9 preceding siblings ...)
  2023-04-18 20:46 ` [Bug c++/105481] [10/11/12 " cvs-commit at gcc dot gnu.org
@ 2023-07-07 10:43 ` rguenth at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

end of thread, other threads:[~2023-07-07 10:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-04 14:48 [Bug c++/105481] New: ICE: unexpected expression of kind template_parm_index chfast at gmail dot com
2022-05-04 14:57 ` [Bug c++/105481] [9/10/11/12/13 Regression] " mpolacek at gcc dot gnu.org
2022-05-04 15:03 ` mpolacek at gcc dot gnu.org
2022-05-05 11:57 ` ppalka at gcc dot gnu.org
2022-05-05 12:29 ` ppalka at gcc dot gnu.org
2022-05-05 12:32 ` ppalka at gcc dot gnu.org
2022-05-27  9:48 ` [Bug c++/105481] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:49 ` jakub at gcc dot gnu.org
2023-03-23 21:50 ` jason at gcc dot gnu.org
2023-03-24 16:32 ` cvs-commit at gcc dot gnu.org
2023-04-18 20:46 ` [Bug c++/105481] [10/11/12 " cvs-commit at gcc dot gnu.org
2023-07-07 10:43 ` [Bug c++/105481] [11 " rguenth 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).