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

            Bug ID: 127640
           Summary: [17 Regression] ICE in contains_polymorphic_type_p
                    with C++26 template for and coroutines under -O2
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bouncy12578 at gmail dot com
  Target Milestone: ---

Created attachment 65710
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65710&action=edit
attached preprocessed file

Compiler Explorer: https://godbolt.org/z/d7daoh9Ex

The compiler crashes while compiling the following code with the following 
compiler options:  g++ -std=c++26 -O2 case.cpp 

Code:

    #include <coroutine>
    struct T {
    struct promise_type {
        T get_return_object() { return {}; }
        std::suspend_never initial_suspend() { return {}; }
        std::suspend_never final_suspend() noexcept { return {}; }
        void return_void() {}
        void unhandled_exception() {}
    };
    };
    T f() { template for (auto c : "a"); co_return; }

Backtrace:

    case.cpp: In function ‘void f(_Z1fv.Frame*)’:
    case.cpp:11:49: internal compiler error: tree check: expected class ‘type’,
have ‘exceptional’ (error_mark) in contains_polymorphic_type_p, at
ipa-polymorphic-call.cc:55
    11 | T f() { template for (auto c : "a"); co_return; }
        |                                                 ^
    0x304b5db internal_error(char const*, ...)
            ../../gcc/gcc/diagnostic-global-context.cc:787
    0xa99e63 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
            ../../gcc/gcc/tree.cc:9297
    0x99596f tree_class_check(tree_node const*, tree_code_class, char const*,
int, char const*)
            ../../gcc/gcc/tree.h:4274
    0x99596f contains_polymorphic_type_p(tree_node const*)
            ../../gcc/gcc/ipa-polymorphic-call.cc:55
    0x15abb69 contains_polymorphic_type_p(tree_node const*)
            ../../gcc/gcc/ipa-polymorphic-call.cc:65
    0x15ac717
ipa_polymorphic_call_context::speculation_consistent_p(tree_node*, long, bool,
tree_node*) const
            ../../gcc/gcc/ipa-polymorphic-call.cc:1868
    0x15ad774
ipa_polymorphic_call_context::combine_speculation_with(tree_node*, long, bool,
tree_node*)
            ../../gcc/gcc/ipa-polymorphic-call.cc:1927
    0x15b1025
ipa_polymorphic_call_context::ipa_polymorphic_call_context(tree_node*,
tree_node*, gimple*, tree_node**)
            ../../gcc/gcc/ipa-polymorphic-call.cc:1117
    0x15ee2bb ipa_compute_jump_functions_for_edge
            ../../gcc/gcc/ipa-prop.cc:2518
    0x15f008a ipa_compute_jump_functions_for_bb
            ../../gcc/gcc/ipa-prop.cc:2747
    0x15f008a analysis_dom_walker::before_dom_children(basic_block_def*)
            ../../gcc/gcc/ipa-prop.cc:3554
    0x2cddc7e dom_walker::walk(basic_block_def*)
            ../../gcc/gcc/domwalk.cc:311
    0x15ed3b9 ipa_analyze_node(cgraph_node*)
            ../../gcc/gcc/ipa-prop.cc:3624
    0x2dc5647 ipcp_generate_summary
            ../../gcc/gcc/ipa-cp.cc:6804
    0x1760a1a execute_ipa_summary_passes(ipa_opt_pass_d*)
            ../../gcc/gcc/passes.cc:2287
    0x12d78a7 ipa_passes
            ../../gcc/gcc/cgraphunit.cc:2268
    0x12d78a7 symbol_table::compile()
            ../../gcc/gcc/cgraphunit.cc:2366
    0x12d9f86 symbol_table::compile()
            ../../gcc/gcc/cgraphunit.cc:2344
    0x12d9f86 symbol_table::finalize_compilation_unit()
            ../../gcc/gcc/cgraphunit.cc:2625
   
/data/lenovo/compiler-build/gcc/gcc-install/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1plus
-quiet -imultiarch x86_64-linux-gnu -D_GNU_SOURCE case.cpp -quiet -dumpdir a-
-dumpbase case.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -O2
-std=c++26 -freport-bug -o /tmp/ccmtJez5.s
    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/ccG1KegK.out file, please attach this
to your bugreport.

The preprocessed file is as attached.
  • [Bug c++/127640] New: [17 Regres... bouncy12578 at gmail dot com via Gcc-bugs

Reply via email to