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

            Bug ID: 105956
           Summary: internal compiler error: in
                    iterative_hash_template_arg, at cp/pt.cc:1819
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msc at linux dot ibm.com
  Target Milestone: ---

Bumped into this error while compiling boost.fiber with upstream GCC:

$ git gcc-descr HEAD
r12-9379-g1158fe43407568

$ "/tmp/gcc-install/bin/gcc" -freport-bug  -fvisibility-inlines-hidden -fPIC
-m64 -pthread -O0 -fno-inline -Wall -g -fvisibility=hidden 
-DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_DYN_LINK=1 -DBOOST_FIBERS_DYN_LINK=1
-DBOOST_FIBERS_SOURCE -DBOOST_FILESYSTEM_DYN_LINK=1  -I"../../.."  -c -o
"../../../bin.v2/libs/fiber/build/gcc-custom/debug/threading-multi/visibility-hidden/scheduler.o"
"../../../libs/fiber/src/scheduler.cpp"
In file included from ../../../boost/intrusive/options.hpp:19,
                 from ../../../boost/intrusive/list_hook.hpp:22,
                 from ../../../boost/intrusive/list.hpp:20,
                 from ../../../boost/fiber/scheduler.hpp:17,
                 from ../../../libs/fiber/src/scheduler.cpp:7:
../../../boost/intrusive/pack_options.hpp: In instantiation of ‘struct
boost::intrusive::invert_typelist_impl<boost::intrusive::typelist<boost::intrusive::slist_defaults,
boost::intrusive::member_hook<boost::fibers::waker_with_hook,
boost::intrusive::slist_member_hook<>,
&boost::fibers::waker_with_hook::waker_queue_hook_>,
boost::intrusive::constant_time_size<false>, boost::intrusive::cache_last<true>
>, boost::intrusive::index_tuple<0, 1, 2, 3> >’:
../../../boost/intrusive/pack_options.hpp:190:71:   required from ‘struct
boost::intrusive::invert_typelist<boost::intrusive::typelist<boost::intrusive::slist_defaults,
boost::intrusive::member_hook<boost::fibers::waker_with_hook,
boost::intrusive::slist_member_hook<>,
&boost::fibers::waker_with_hook::waker_queue_hook_>,
boost::intrusive::constant_time_size<false>, boost::intrusive::cache_last<true>
> >’
../../../boost/intrusive/pack_options.hpp:230:55:   required from ‘struct
boost::intrusive::pack_options<boost::intrusive::slist_defaults,
boost::intrusive::member_hook<boost::fibers::waker_with_hook,
boost::intrusive::slist_member_hook<>,
&boost::fibers::waker_with_hook::waker_queue_hook_>,
boost::intrusive::constant_time_size<false>, boost::intrusive::cache_last<true>
>’
../../../boost/intrusive/slist.hpp:2149:15:   required from ‘struct
boost::intrusive::make_slist<boost::fibers::waker_with_hook,
boost::intrusive::member_hook<boost::fibers::waker_with_hook,
boost::intrusive::slist_member_hook<>,
&boost::fibers::waker_with_hook::waker_queue_hook_>,
boost::intrusive::constant_time_size<false>, boost::intrusive::cache_last<true>
>’
../../../boost/intrusive/slist.hpp:2173:7:   required from ‘class
boost::intrusive::slist<boost::fibers::waker_with_hook,
boost::intrusive::member_hook<boost::fibers::waker_with_hook,
boost::intrusive::slist_member_hook<>,
&boost::fibers::waker_with_hook::waker_queue_hook_>,
boost::intrusive::constant_time_size<false>, boost::intrusive::cache_last<true>
>’
../../../boost/fiber/waker.hpp:73:36:   required from here
../../../boost/intrusive/pack_options.hpp:164:29: internal compiler error: in
iterative_hash_template_arg, at cp/pt.cc:1819
  164 |    static const std::size_t last_idx = sizeof_typelist<Typelist>::value
- 1;
      |                             ^~~~~~~~
0x6ec942 iterative_hash_template_arg(tree_node*, unsigned int)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:1819
0xb105c5 iterative_hash_template_arg(tree_node*, unsigned int)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:1829
0xb10fc8 hash_tmpl_and_args
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:1769
0xb10fc8 spec_hasher::hash(tree_node*, tree_node*)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:1776
0xb3389b tsubst_decl
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:14991
0xb26d87 tsubst_copy
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:17066
0xb2a720 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:21390
0xb2a2f6 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:20434
0xb2bb15 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:20283
0xb35d08 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:19595
0xb4b4dc tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:13580
0xb54d8f tsubst_aggr_type
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:13796
0xb54d8f tsubst_aggr_type
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:13753
0xb49154 tsubst(tree_node*, tree_node*, int, tree_node*)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:16282
0xb35497 gen_elem_of_pack_expansion_instantiation
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:12749
0xb35497 tsubst_pack_expansion(tree_node*, tree_node*, int, tree_node*)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:13417
0xb4b6e2 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:13566
0xb4b905 tsubst_argument_pack(tree_node*, tree_node*, int, tree_node*)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:13517
0xb4b6b4 tsubst_template_args(tree_node*, tree_node*, int, tree_node*)
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:13578
0xb54d8f tsubst_aggr_type
        /home/mscastanho/dev/gcc/gcc/cp/pt.cc:13796
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Preprocessed source stored into /tmp/ccVLIwjb.out file, please attach this to
your bugreport.


I'm not that familiar with the code to be able to create a smaller reproducer,
but I'm attaching the pre-processed source generated by -freport-bug.

I was able to reproduce this both on ppc64le and x86_64. GCC configured with:
<gcc-path>/configure --prefix=/tmp/gcc-install --enable-languages=c,c++
--disable-bootstrap --disable-multilib


After doing a quick bisect I suspect the issue was introduced by the following
commit:

commit cb7fd1ea85feea7ef65328330fc2577a95e99400
Author: Patrick Palka <ppa...@redhat.com>
Date:   Fri Jun 10 16:09:48 2022 -0400

    c++: optimize specialization of nested templated classes

Reply via email to