https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116808
Bug ID: 116808 Summary: Valgrind reports mismatched new/delete in value-range.h Product: gcc Version: 13.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org Target Milestone: --- I see this with 13 and 14/15 are fine. Hit it when looking at https://bugs.gentoo.org/939997 (which I can't reproduce). ``` $ g++-13 -c z.ii -march=skylake -O2 -fPIC -wrapper valgrind,--track-origins=yes,--exit-on-first-error=yes,--error-exitcode=2 ==3378487== Memcheck, a memory error detector ==3378487== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al. ==3378487== Using Valgrind-3.24.0.GIT and LibVEX; rerun with -h for copyright info ==3378487== Command: /usr/libexec/gcc/x86_64-pc-linux-gnu/13/cc1plus -fpreprocessed z.ii -quiet -dumpbase z.ii -dumpbase-ext .ii -march=skylake -O2 -fPIC -o /tmp/ccIEnzhk.s ==3378487== ==3378487== Mismatched new/delete size value: 8 ==3378487== at 0x484EDEE: operator delete(void*, unsigned long) (vg_replace_malloc.c:1181) ==3378487== by 0x2A37596: ~int_range (value-range.h:507) ==3378487== by 0x2A37596: ~Value_Range (value-range.h:538) ==3378487== by 0x2A37596: gimple_ranger::range_of_stmt(vrange&, gimple*, tree_node*) (gimple-range.cc:326) ==3378487== by 0x1CE3EFD: range_query::value_of_stmt(gimple*, tree_node*) (value-query.cc:134) ==3378487== by 0x1B6C27F: substitute_and_fold_dom_walker::before_dom_children(basic_block_def*) (tree-ssa-propagate.cc:792) ==3378487== by 0x29F7A2E: dom_walker::walk(basic_block_def*) (domwalk.cc:311) ==3378487== by 0x1B6AF2E: substitute_and_fold_engine::substitute_and_fold(basic_block_def*) (tree-ssa-propagate.cc:971) ==3378487== by 0x1CA90E1: execute_ranger_vrp(function*, bool, bool) (tree-vrp.cc:1107) ==3378487== by 0x180C029: execute_one_pass(opt_pass*) (passes.cc:2651) ==3378487== by 0x180CE6A: execute_pass_list_1(opt_pass*) (passes.cc:2760) ==3378487== by 0x180D266: execute_pass_list_1 (passes.cc:2761) ==3378487== by 0x180D266: execute_pass_list(function*, opt_pass*) (passes.cc:2771) ==3378487== by 0x180DFFA: do_per_function_toporder (passes.cc:1780) ==3378487== by 0x180DFFA: do_per_function_toporder (passes.cc:1743) ==3378487== by 0x180DFFA: execute_ipa_pass_list(opt_pass*) (passes.cc:3105) ==3378487== by 0x1350733: ipa_passes (cgraphunit.cc:2210) ==3378487== by 0x1350733: symbol_table::compile() [clone .part.0] (cgraphunit.cc:2333) ==3378487== Address 0x86f62b0 is 0 bytes inside a block of size 4,080 alloc'd ==3378487== at 0x484CA4F: operator new[](unsigned long) (vg_replace_malloc.c:729) ==3378487== by 0x1CEB0F6: irange::maybe_resize(int) [clone .part.0] (value-range.h:496) ==3378487== by 0x1CF714A: maybe_resize (value-range.cc:2417) ==3378487== by 0x1CF714A: irange::irange_union(irange const&) (value-range.cc:2513) ==3378487== by 0x12D047C: irange::union_(vrange const&) (value-range.h:1059) ==3378487== by 0x2BA8F3F: range_operator::wi_fold_in_parts(irange&, tree_node*, generic_wide_int<wide_int_storage> const&, generic_wide_int<wide_int_storage> const&, generic_wide_int<wide_int_storage> const&, generic_wide_int<wide_int_storage> const&) const (range-op.cc:245) ==3378487== by 0x2BA9872: range_operator::fold_range(irange&, tree_node*, irange const&, irange const&, relation_trio) const (range-op.cc:296) ==3378487== by 0x2BA9B9E: operator_lshift::fold_range(irange&, tree_node*, irange const&, irange const&, relation_trio) const (range-op.cc:2403) ==3378487== by 0x2A491C0: fold_using_range::range_of_range_op(vrange&, gimple_range_op_handler&, fur_source&) (gimple-range-fold.cc:589) ==3378487== by 0x2A4A512: fold_using_range::fold_stmt(vrange&, gimple*, fur_source&, tree_node*) (gimple-range-fold.cc:489) ==3378487== by 0x2A37542: fold_range_internal (gimple-range.cc:257) ==3378487== by 0x2A37542: gimple_ranger::range_of_stmt(vrange&, gimple*, tree_node*) (gimple-range.cc:318) ==3378487== by 0x1CE3EFD: range_query::value_of_stmt(gimple*, tree_node*) (value-query.cc:134) ==3378487== by 0x1B6C27F: substitute_and_fold_dom_walker::before_dom_children(basic_block_def*) (tree-ssa-propagate.cc:792) ==3378487== ==3378487== ==3378487== Exit program on first error (--exit-on-first-error=yes) ``` -- ``` $ gcc-13 -v Using built-in specs. COLLECT_GCC=gcc-13 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/13/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-13.3.1_p20240920/work/gcc-13-20240920/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/13 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13 --disable-silent-rules --disable-dependency-tracking --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/13/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --disable-nls --disable-libunwind-exceptions --enable-checking=yes,extra,rtl --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 13.3.1_p20240920 p18' --with-gcc-major-version-only --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-cet --disable-systemtap --enable-valgrind-annotations --disable-vtable-verify --disable-libvtv --with-zstd --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp --disable-fixincludes --with-build-config=bootstrap-O3 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 13.3.1 20240920 (Gentoo Hardened 13.3.1_p20240920 p18) ```