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

            Bug ID: 125591
           Summary: ICE in tsubst_pack_expansion with C++26 structured
                    binding packs and fold expressions
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: willsmithofficial2222 at gmail dot com
  Target Milestone: ---

Created attachment 64618
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64618&action=edit
Preprocessed source file

An internal compiler error occurs when attempting to expand a structured
binding  pack directly into a fold expression.

The following code compiles with Clang, but fails with all GCC 16.1.0 (and
trunk) compilers available on godbolt.org:

template<typename T, typename U>
concept is_same_v = __is_same(T, U);

struct Vec3 { int x, y, z; };

template<class V>
consteval bool hasSameTypes() {
    constexpr auto [...Ms] = V{};
    using T = decltype(Ms...[0]);
    // ICE: in tsubst_pack_expansion, at cp/pt.cc:14250
    return (is_same_v<decltype(Ms), T> && ...);
    // Workaround:
    // return []<class... Ts> { return (is_same_v<Ts, T> && ...); }.template
operator()<decltype(Ms)...>();
}

int main() {
    return hasSameTypes<Vec3>() ? 0 : 1;
}


Compiler flags: -std=c++26 -Wall -Werror

Godbolt link: https://godbolt.org/z/jh8n6PPTv
  • [Bug c++/125591] New: ... willsmithofficial2222 at gmail dot com via Gcc-bugs

Reply via email to