https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117037
Bug ID: 117037 Summary: gcc14.2.1 riscv64-unknown-linux-gnu-g++ build opencv 5.x error Product: gcc Version: 14.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: bigmagicreadsun at gmail dot com Target Milestone: --- When compiling OpenCV 5.x with riscv64-unknown-linux-gnu-g++, the following error occurs. set(CMAKE_C_FLAGS_INIT "-march=rv64imafdcv -mabi=lp64d -O3 -static") set(CMAKE_CXX_FLAGS_INIT "-march=rv64imafdcv -mabi=lp64d -O3 -static") opencv/modules/dnn/src/layers/reduce_layer.cpp: In member function 'void cv::dnn::ReduceLayerImpl::ReduceAllInvoker<Op>::operator()(const cv::Range&) const [with Op = cv::dnn::ReduceLayerImpl::ReduceProd<signed char>]': /Local/home/zhaofujin/opencv/opencv/modules/dnn/src/layers/reduce_layer.cpp:290:14: internal compiler error: in vect_create_partial_epilog, at tree-vect-loop.cc:5866 290 | void operator()(const Range& r) const CV_OVERRIDE { | ^~~~~~~~ 0x7f5a1f485082 __libc_start_main ../csu/libc-start.c:308 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. make[2]: *** [modules/dnn/CMakeFiles/opencv_dnn.dir/build.make:1181: modules/dnn/CMakeFiles/opencv_dnn.dir/src/layers/reduce_layer.cpp.o] Error 1 make[2]: *** Waiting for unfinished jobs.... The code where the error occurs in reduce_layer.cpp is as follows: ReduceAllInvoker(const Mat& src_, Mat& dst_) : src(src_), dst(dst_) { auto shape_src = shape(src); n_reduce = std::accumulate(shape_src.begin(), shape_src.end(), 1, std::multiplies<int>()); loop_size = n_reduce; total = 1; cost_per_thread = 1; } void operator()(const Range& r) const CV_OVERRIDE { int start = r.start; int end = r.end; const dtype* p_src = src.ptr<const dtype>(); dtype* p_dst = dst.ptr<dtype>(); for (int i = start; i < end; ++i) { Op accumulator(n_reduce, *p_src); for (int l = 0; l < loop_size; ++l) { accumulator.update(p_src[l]); } p_dst[i] = accumulator.get_value(); } } This error seems to be related to g++'s generation logic for RVV.