<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Compiler hanging in loop with recursive templates in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Compiler-hanging-in-loop-with-recursive-templates/m-p/1715977#M4555</link>
    <description>&lt;P&gt;I wonder if this could be a bug with the compiler?&lt;/P&gt;&lt;P&gt;In the following function, adding a dummy call to my template allows the compiler to complete its process. If I remove the lines with the "empty" BoardState, the compiler hangs (process clang-cl).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;template &amp;lt;int depth, bool side, bool wKMoved, bool bKMoved, Piece piece&amp;gt;
ForceInline void makeMoves(U64&amp;amp; nodes, U64 attacks, int from, BoardState&amp;amp; board, int kES) {
    int to;
    U64 moves = attacks &amp;amp; ~board.occE;
    Bitloop(moves) {
        to = SquareOf(moves);

        BoardState newBoard = board.make&amp;lt;piece, side, false&amp;gt;(from, to, board, kES);
        if constexpr (piece == Piece::King) {
            if constexpr (side == white)    nodes += PerftGenerator&amp;lt;depth - 1, !side, true, bKMoved&amp;gt;::generateMoves(newBoard);
            else                            nodes += PerftGenerator&amp;lt;depth - 1, !side, wKMoved, true&amp;gt;::generateMoves(newBoard);
        }
        else {
            nodes += PerftGenerator&amp;lt;depth - 1, !side, wKMoved, bKMoved&amp;gt;::generateMoves(newBoard);

            BoardState empty = BoardState(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            PerftGenerator&amp;lt;depth - 1, !side, wKMoved, bKMoved&amp;gt;::generateMoves(empty);
        }
    }

    moves = attacks &amp;amp; board.occE;
    Bitloop(moves) {
        to = SquareOf(moves);

        BoardState newBoard = board.make&amp;lt;piece, side, true&amp;gt;(from, to, board, kES);
        if constexpr (piece == Piece::King) {
            if constexpr (side == white)    nodes += PerftGenerator&amp;lt;depth - 1, !side, true, bKMoved&amp;gt;::generateMoves(newBoard);
            else                            nodes += PerftGenerator&amp;lt;depth - 1, !side, wKMoved, true&amp;gt;::generateMoves(newBoard);
        }
        else {
            nodes += PerftGenerator&amp;lt;depth - 1, !side, wKMoved, bKMoved&amp;gt;::generateMoves(newBoard);

            BoardState empty = BoardState(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            PerftGenerator&amp;lt;depth - 1, !side, wKMoved, bKMoved&amp;gt;::generateMoves(empty);
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;Another funny thing is that with my "King", it still compiles, so I didn't have to add the dummy call, but for all other pieces it doesn't. However, the same template/code is executed. I tried to only keep the code that the King executes to test, but it was hanging nonetheless.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Please do not suggest to remove the forced inlining, my only goal is to make the fastest code possible. It compiles without "__forceinline" but performance takes a huge hit, and it's not the question anyway.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Sep 2025 13:58:14 GMT</pubDate>
    <dc:creator>CoderJoe</dc:creator>
    <dc:date>2025-09-09T13:58:14Z</dc:date>
    <item>
      <title>Compiler hanging in loop with recursive templates</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Compiler-hanging-in-loop-with-recursive-templates/m-p/1715977#M4555</link>
      <description>&lt;P&gt;I wonder if this could be a bug with the compiler?&lt;/P&gt;&lt;P&gt;In the following function, adding a dummy call to my template allows the compiler to complete its process. If I remove the lines with the "empty" BoardState, the compiler hangs (process clang-cl).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;template &amp;lt;int depth, bool side, bool wKMoved, bool bKMoved, Piece piece&amp;gt;
ForceInline void makeMoves(U64&amp;amp; nodes, U64 attacks, int from, BoardState&amp;amp; board, int kES) {
    int to;
    U64 moves = attacks &amp;amp; ~board.occE;
    Bitloop(moves) {
        to = SquareOf(moves);

        BoardState newBoard = board.make&amp;lt;piece, side, false&amp;gt;(from, to, board, kES);
        if constexpr (piece == Piece::King) {
            if constexpr (side == white)    nodes += PerftGenerator&amp;lt;depth - 1, !side, true, bKMoved&amp;gt;::generateMoves(newBoard);
            else                            nodes += PerftGenerator&amp;lt;depth - 1, !side, wKMoved, true&amp;gt;::generateMoves(newBoard);
        }
        else {
            nodes += PerftGenerator&amp;lt;depth - 1, !side, wKMoved, bKMoved&amp;gt;::generateMoves(newBoard);

            BoardState empty = BoardState(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            PerftGenerator&amp;lt;depth - 1, !side, wKMoved, bKMoved&amp;gt;::generateMoves(empty);
        }
    }

    moves = attacks &amp;amp; board.occE;
    Bitloop(moves) {
        to = SquareOf(moves);

        BoardState newBoard = board.make&amp;lt;piece, side, true&amp;gt;(from, to, board, kES);
        if constexpr (piece == Piece::King) {
            if constexpr (side == white)    nodes += PerftGenerator&amp;lt;depth - 1, !side, true, bKMoved&amp;gt;::generateMoves(newBoard);
            else                            nodes += PerftGenerator&amp;lt;depth - 1, !side, wKMoved, true&amp;gt;::generateMoves(newBoard);
        }
        else {
            nodes += PerftGenerator&amp;lt;depth - 1, !side, wKMoved, bKMoved&amp;gt;::generateMoves(newBoard);

            BoardState empty = BoardState(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
            PerftGenerator&amp;lt;depth - 1, !side, wKMoved, bKMoved&amp;gt;::generateMoves(empty);
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;Another funny thing is that with my "King", it still compiles, so I didn't have to add the dummy call, but for all other pieces it doesn't. However, the same template/code is executed. I tried to only keep the code that the King executes to test, but it was hanging nonetheless.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Please do not suggest to remove the forced inlining, my only goal is to make the fastest code possible. It compiles without "__forceinline" but performance takes a huge hit, and it's not the question anyway.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Sep 2025 13:58:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/Compiler-hanging-in-loop-with-recursive-templates/m-p/1715977#M4555</guid>
      <dc:creator>CoderJoe</dc:creator>
      <dc:date>2025-09-09T13:58:14Z</dc:date>
    </item>
  </channel>
</rss>

