[Bug c++/93248] New: ICE in decltype of template constructor with default argument within a class template

rene.rahn@fu-berlin.de gcc-bugzilla@gcc.gnu.org
Mon Jan 13 10:07:00 GMT 2020


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

            Bug ID: 93248
           Summary: ICE in decltype of template constructor with default
                    argument within a class template
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rene.rahn@fu-berlin.de
  Target Milestone: ---

Hi gcc team,

I stumbled over the following weird scenario causing an ICE with gcc>=8.3 but
seems to be fine for the gcc 7 series.

Here is the code in question:

```
#include <vector>

template <typename t>
struct foo
{
    template <typename some_t>
    constexpr foo(t const it,
                  some_t const index,
                  size_t const my_index = 0) :
        m_it{it},
        m_index{index},
        m_my_index{my_index}
    {}

    t m_it{};
    size_t m_index{};
    size_t m_my_index{};
};

int main()
{
    using foo_t = decltype(foo{10, 4u, 2}); // works
    // using foo_ice_t = decltype(foo{10, 4u}); // ICE: type deduction in
decltype seems to cause this?
    using foo_fine_t = decltype(foo<size_t>{10, 4u}); // explicit type
declaration works fine.

    foo f{10, 3u}; // works fine out of decltype expression.
}

```

The second decltype expression for foo_ice_t causes an ICE for gcc>=8.1 but not
for gcc7.5. If I use the type deduction to create an object of foo everything
works as expected. Can you help me with this?

Many thanks in advance.


More information about the Gcc-bugs mailing list