https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97347
Bug ID: 97347 Summary: [11 Regression] error: statement marked for throw in middle of block in botan Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: marxin at gcc dot gnu.org CC: rguenth at gcc dot gnu.org Target Milestone: --- The following fails: $ cat botan.ii inline namespace __cxx11 {} typedef int size_t; class MessageAuthenticationCode; class __uniq_ptr_impl { struct _Ptr { using type = MessageAuthenticationCode *; }; public: using pointer = _Ptr::type; }; class unique_ptr { public: using pointer = __uniq_ptr_impl::pointer; unique_ptr(pointer); }; namespace __cxx11 { class basic_string { public: basic_string(char *); ~basic_string(); }; } // namespace __cxx11 class MessageAuthenticationCode {}; class SCAN_Name { public: SCAN_Name(basic_string); size_t arg_as_integer(); }; class SipHash : public MessageAuthenticationCode { public: SipHash(size_t c, size_t d) : m_C(c), m_D(d) {} size_t m_C, m_D; }; void create(basic_string algo_spec) { basic_string provider = ""; SCAN_Name req(algo_spec); unique_ptr(new SipHash(req.arg_as_integer(), req.arg_as_integer())); } $ g++ -O3 botan.ii -c -fdump-tree-all botan.ii: In function ‘void create(__cxx11::basic_string)’: botan.ii:35:27: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings] 35 | basic_string provider = ""; | ^~ botan.ii:34:6: error: statement marked for throw in middle of block 34 | void create(basic_string algo_spec) { | ^~~~~~ # .MEM_11 = VDEF <.MEM_9> _12 = operator new (8); during GIMPLE pass: slp dump file: botan.ii.175t.slp2 botan.ii:34:6: internal compiler error: verify_gimple failed 0x1057d5a verify_gimple_in_cfg(function*, bool) /home/marxin/Programming/gcc/gcc/tree-cfg.c:5482 0xf3d36f execute_function_todo /home/marxin/Programming/gcc/gcc/passes.c:1992 0xf3e1bc do_per_function /home/marxin/Programming/gcc/gcc/passes.c:1640 0xf3e1bc execute_todo /home/marxin/Programming/gcc/gcc/passes.c:2046 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. The insertion code mentions statements that can throw but does not handle it. Patch candidate: diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 7e22506b49f..84bc8970f33 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -4148,13 +4148,22 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree op_node) gsi = gsi_for_stmt (insert_after->stmt); else { - /* When we want to insert after a def where the - defining stmt throws then insert on the fallthru - edge. */ edge e = find_fallthru_edge (gimple_bb (insert_after->stmt)->succs); gcc_assert (single_pred_p (e->dest)); gsi = gsi_after_labels (e->dest); + + /* When we want to insert after a def where the + defining stmt throws then insert on the fallthru + edge. */ + while (!gsi_end_p (gsi) + && stmt_can_throw_internal (cfun, gsi_stmt (gsi))) + { + e = find_fallthru_edge (e->dest->succs); + gcc_assert (single_pred_p (e->dest)); + gsi = gsi_after_labels (e->dest); + } + } gsi_insert_seq_after (&gsi, ctor_seq, GSI_CONTINUE_LINKING); What do you think Richi about the patch?