[Bug c++/107332] New: internal compiler error: in tsubst_copy, at cp/pt.c:15751

dreamcooled at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Oct 20 10:34:18 GMT 2022


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

            Bug ID: 107332
           Summary: internal compiler error: in tsubst_copy, at
                    cp/pt.c:15751
           Product: gcc
           Version: 9.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dreamcooled at gmail dot com
  Target Milestone: ---

I'm getting an ICE when compiling the following program on x86-64 gcc 9.5.
Tried it on godbolt.org with -std=c++17 command line options.
The bug seems to be fixed in > gcc 10.

#include <type_traits>

template <typename T> void Invoke()
{
    auto f = [](auto stateIdIntegralConstant) {
        if constexpr
(std::integral_constant<std::size_t,stateIdIntegralConstant>() == 0)
        {
        }
    };
    f(std::integral_constant<std::size_t, 0>{});
}

int main()
{
   Invoke<int>();
}


Compiler output:
<source>: In instantiation of 'Invoke() [with T = int]::<lambda(auto:1)> [with
auto:1 = std::integral_constant<long unsigned int, 0>]':
<source>:10:6:   required from 'void Invoke() [with T = int]'
<source>:15:16:   required from here
<source>:6:28: internal compiler error: in tsubst_copy, at cp/pt.c:15751
    6 |         if constexpr
(std::integral_constant<std::size_t,stateIdIntegralConstant>() == 0)
      |                           
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1


I see there are possible duplicates of this bug, but all are in state
resolved/fixed and I'm not sure if it is really the same bug.
If it is the same bug, I was hoping that the fix could be backported to gcc 9,
since I'm using only standard c++17 without any experimental features...

Thank You.


More information about the Gcc-bugs mailing list