Thursday, February 3, 2022

[SOLVED] How to report this ICE for gcc-trunk

Issue

I would like to get this code work

#include <cstddef>

template <bool B, auto T, auto F>
struct conditional { static constexpr auto value = T; };

template <auto T, auto F>
struct conditional<false, T, F> { static constexpr auto value = F; };

template <std::size_t N, auto... Dims>
struct static_extent;

template <std::size_t N>
struct static_extent<N> {
   static constexpr std::size_t value = 0;
};

template <std::size_t N, auto Dim, auto... Dims>
struct static_extent<N, Dim, Dims...> {
  static constexpr auto value =
     conditional<
        (N == 0),
        Dim,
        static_extent<N-1, Dims...>::value
     >::value;
};

enum class dynamic_extent_tag {};
inline constexpr dynamic_extent_tag dyn{-1};

int main()
{
    static_assert(static_extent<1, 33, dyn, 19>::value == dyn, "");
    static_assert(static_extent<0, 33, dyn, 19>::value == 33, "");
}

I have tested it on godbolt and it seems to work with clang. I am unfortunately bound to gcc which gives me an ICE plus a stack trace. I tried to surf on their bugzilla and i am kinda lost.

Is it even worth to put up an bug report for the trunk version? Is it even wanted? Does someone knows if it is already a known problem? I looked for the keyword "ice" but I could not find anything useful there.


Solution

Yes, all ICEs should be reported.

I've opened https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79556 for you.

Thanks.



Answered By - octoploid
Answer Checked By - Gilberto Lyons (WPSolving Admin)