https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110508
Bug ID: 110508 Summary: ICE (Segfault) during widening_mul, in match_uaddc_usubc Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: ali.mpfard at gmail dot com Target Milestone: --- Created attachment 55437 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55437&action=edit Original preprocessed source GCC trunk (commit db38b285ba61c5b888adc0d117177bfd774c1153, not bisected) segfaults when compiling the reduced source below (also attached: full preprocessed source), also related to #79173 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79173>. // Target: x86_64-pc-linux-gnu // Configured with: ./configure --prefix=/opt/gcc --disable-nls --disable-libstdcxx-pch --enable-shared --enable-languages=c,c++ --enable-default-pie --enable-lto --enable-threads=posix // Thread model: posix // Supported LTO compression algorithms: zlib zstd // gcc version 14.0.0 20230630 (experimental) (GCC) // // secp.cpp: In instantiation of 'static void Detail::StorageOperations::add(auto:1) [with int <anonymous> = 0; auto:1 = int]': // secp.cpp:23:34: required from 'void Detail::UFixedBigInt::addc(T, bool) [with T = Detail::UFixedBigInt]' // secp.cpp:31:12: required from here // secp.cpp:9:11: error: reference 'carry' is initialized with itself [-Werror=init-self] // 9 | bool &carry = carry; // | ^~~~~ // secp.cpp:11:9: error: unused variable 'outputoutput' [-Werror=unused-variable] // 11 | outputoutput = // | ^~~~~~~~~~~~ // secp.cpp: In static member function 'static void Detail::StorageOperations::add(auto:1) [with int <anonymous> = 0; auto:1 = int]': // secp.cpp:9:11: error: 'carry' is used uninitialized [-Werror=uninitialized] // 9 | bool &carry = carry; // | ^~~~~ // secp.cpp:9:11: note: 'carry' was declared here // 9 | bool &carry = carry; // | ^~~~~ // during GIMPLE pass: widening_mul // secp.cpp: In function 'void modular_multiply()': // secp.cpp:29:6: internal compiler error: Segmentation fault // 29 | void modular_multiply() { // | ^~~~~~~~~~~~~~~~ // 0x149fb7f crash_signal // ../.././gcc/toplev.cc:314 // 0xe80858 gimple_bb(gimple const*) // ../.././gcc/gimple.h:1905 // 0x114529c gsi_for_stmt(gimple*) // ../.././gcc/gimple-iterator.cc:617 // 0x1640ff7 match_uaddc_usubc // ../.././gcc/tree-ssa-math-opts.cc:4864 // 0x164b6ce after_dom_children // ../.././gcc/tree-ssa-math-opts.cc:5589 // 0x217dbba dom_walker::walk(basic_block_def*) // ../.././gcc/domwalk.cc:354 // 0x163c836 execute // ../.././gcc/tree-ssa-math-opts.cc:5666 // 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. // /opt/gcc/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/cc1plus -quiet -D_GNU_SOURCE secp.cpp -quiet -dumpdir a- -dumpbase secp.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g1 -O2 -Wall -Wextra -Wno-unknown-warning-option -Wno-unused-command-line-argument -Werror -Wno-expansion-to-defined -Wno-literal-suffix -Wno-dangling-reference -Wno-maybe-uninitialized -Wno-shorten-64-to-32 -Wvla -std=c++20 -fno-exceptions -fsigned-char -fno-semantic-interposition -fPIC -freport-bug -o - -frandom-seed=0 -fdump-noaddr # 0 "secp.cpp" # 1 "/home/test/Workspace/serenity/reduce//" # 0 "<built-in>" # 0 "<command-line>" # 1 "/usr/include/stdc-predef.h" 1 3 4 # 0 "<command-line>" 2 # 1 "secp.cpp" template <typename, typename> constexpr bool IsSame = false; namespace Detail { typedef long NativeWord; struct IntegerWrapper; long add_words_word1; long add_words_word2; struct StorageOperations { template <int> static void add(auto) { bool &carry = carry; NativeWord ncarry, outputoutput = __builtin_addcl(add_words_word1, add_words_word2, carry, reinterpret_cast<unsigned long *>(&ncarry)); carry = ncarry; } }; template <typename T> concept UFixedInt = ! IsSame<T, IntegerWrapper>; int m_data; struct UFixedBigInt { template <UFixedInt T> void addc(T, bool) { StorageOperations::add<false>(m_data); } }; } using Detail::UFixedBigInt; bool modular_multiply_carry; void modular_multiply() { UFixedBigInt mult, mp; mult.addc(mp, modular_multiply_carry); }