https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111752
Bug ID: 111752 Summary: -Wfree-nonheap-object (vec.h:347:10: warning: 'free' called on unallocated object 'dest_bbs') during bootstrap with LTO Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org Target Milestone: --- I'm not sure this was always there - I think I would've noticed if it was a long-standing thing. I get this -Wfree-nonheap-object warning during bootstrap. I can reproduce it with: ``` ./configure --disable-analyzer --disable-bootstrap --disable-cet --disable-default-pie --disable-default-ssp --disable-fixincludes --disable-gcov --disable-libada --disable-libatomic --disable-libgomp --disable-libitm --disable-libquadmath --disable-libsanitizer --disable-libssp --disable-libstdcxx-pch --disable-libvtv --disable-lto --disable-multilib --disable-nls --disable-objc-gc --disable-systemtap --disable-werror --enable-languages=c,c++ --prefix=/tmp/bisect --without-isl --without-zstd --with-system-zlib --enable-bootstrap --enable-lto make BUILD_CONFIG=bootstrap-lto -j$(nproc) ``` I can only reproduce when building with bootstrap-lto. On trunk at r14-4523-gfb124f2a23e92b, I get this: ``` /home/sam/git/gcc/host-x86_64-pc-linux-gnu/prev-gcc/xg++ -B/home/sam/git/gcc/host-x86_64-pc-linux-gnu/prev-gcc/ -B/tmp/bisect/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/home/sam/git/gcc/prev-x86_64-pc-linux-gnu/ libstdc++-v3/src/.libs -B/home/sam/git/gcc/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -I/home/sam/git/gcc/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu -I/home/sam/git/gcc/pre v-x86_64-pc-linux-gnu/libstdc++-v3/include -I/home/sam/git/gcc/libstdc++-v3/libsupc++ -L/home/sam/git/gcc/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/sam/git/gcc/prev-x86_64-pc-linux-gnu/libstdc+ +-v3/libsupc++/.libs -no-pie -g -O2 -fno-checking -flto=jobserver -frandom-seed=1 -DIN_GCC -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmis sing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -no-pie -static-libstdc++ -static-libgcc -o cc1plus \ cp/cp-lang.o c-family/stub-objc.o cp/call.o cp/class.o cp/constexpr.o cp/constraint.o cp/coroutines.o cp/cp-gimplify.o cp/cp-objcp-common.o cp/cp-ubsan.o cp/cvt.o cp/contracts.o cp/cxx-pretty-print.o cp /decl.o cp/decl2.o cp/dump.o cp/error.o cp/except.o cp/expr.o cp/friend.o cp/init.o cp/lambda.o cp/lex.o cp/logic.o cp/mangle.o cp/mapper-client.o cp/mapper-resolver.o cp/method.o cp/module.o cp/name-lookup.o cp/optimize.o cp/parser.o cp/pt.o cp/ptree.o cp/rtti.o cp/search.o cp/semantics.o cp/tree.o cp/typeck.o cp/typeck2.o cp/vtable-class-hierarchy.o attribs.o c-family/c-common.o c-family/c-cppbuiltin.o c-family /c-dump.o c-family/c-format.o c-family/c-gimplify.o c-family/c-indentation.o c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-pr int.o c-family/c-semantics.o c-family/c-ada-spec.o c-family/c-ubsan.o c-family/known-headers.o c-family/c-attribs.o c-family/c-warn.o c-family/c-spellcheck.o i386-c.o glibc-c.o cc1plus-checksum.o libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a ../libcody/libcody.a \ libcommon.a ../libcpp/libcpp.a ../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a -lmpc -lmpfr -lgmp -rdynamic -lz ../.././gcc/spellcheck.cc: In function '_Z17get_edit_distancePKciS0_i.part.0': ../.././gcc/spellcheck.cc:71:61: warning: argument 1 value '18446744073709551615' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=] 71 | edit_distance_t *v_two_ago = new edit_distance_t[len_s + 1]; | ^ /home/sam/git/gcc/libstdc++-v3/libsupc++/new:133:26: note: in a call to allocation function 'operator new []' declared here 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^ ../.././gcc/spellcheck.cc:72:61: warning: argument 1 value '18446744073709551615' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=] 72 | edit_distance_t *v_one_ago = new edit_distance_t[len_s + 1]; | ^ /home/sam/git/gcc/libstdc++-v3/libsupc++/new:133:26: note: in a call to allocation function 'operator new []' declared here 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^ ../.././gcc/spellcheck.cc:73:58: warning: argument 1 value '18446744073709551615' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=] 73 | edit_distance_t *v_next = new edit_distance_t[len_s + 1]; | ^ /home/sam/git/gcc/libstdc++-v3/libsupc++/new:133:26: note: in a call to allocation function 'operator new []' declared here 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) In function 'release', inlined from 'release' at ../.././gcc/vec.h:2027:20, inlined from '__dt_base ' at ../.././gcc/vec.h:1686:19, inlined from 'can_be_handled' at ../.././gcc/tree-switch-conversion.cc:1512:1: ../.././gcc/vec.h:347:10: warning: 'free' called on unallocated object 'dest_bbs' [-Wfree-nonheap-object] 347 | ::free (v); | ^ ../.././gcc/tree-switch-conversion.cc: In function 'can_be_handled': ../.././gcc/tree-switch-conversion.cc:1484:39: note: declared here 1484 | auto_vec<int, m_max_case_bit_tests> dest_bbs; | ^ [...] ```