From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 444873858C00; Fri, 3 Nov 2023 15:13:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 444873858C00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699024388; bh=3ETHE2u4mCwatcP4cORjyC50McxlKPjjizsKBfEx70M=; h=From:To:Subject:Date:From; b=XyC6UA+Kw7d0VP6tNNQkcTL9CTBGJnI5myGm449zx2A/i+Naz2ttEV1VS90XYZ20l 7LxDqvU260Ow4z/L0pjbd/sOTK5akIfnjeZncNUo9fbwH++4DihEn9U7q0m3Y0Oe9n 9r5JD4nw80AHaC/Ivyz5jML4k7ffYE3MogmNx0VA= From: "alexander.grund@tu-dresden.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/112370] New: -Wfree-nonheap-object in std::vector dtor on sapphirerapids with -O3 Date: Fri, 03 Nov 2023 15:13:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: alexander.grund@tu-dresden.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112370 Bug ID: 112370 Summary: -Wfree-nonheap-object in std::vector dtor on sapphirerapids with -O3 Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: alexander.grund@tu-dresden.de Target Milestone: --- I have some code (from PTorch) which shows a bogus -Wfree-nonheap-object warning when compiled with `-O3 -march=3Dsapphirerapids`: In file included from /software/GCCcore/12.2.0/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/c++all= ocator.h:33, from /software/GCCcore/12.2.0/include/c++/12.2.0/bits/allocator.h:46, from /software/GCCcore/12.2.0/include/c++/12.2.0/memory:64, from /src/third_party/ideep/mkl-dnn/src/utils/compatible.hpp:23, from /src/third_party/ideep/mkl-dnn/src/backend/dnnl/dnnl_backend.cpp:19: In member function 'void std::__new_allocator<_Tp>::deallocate(_Tp*, size_t= ype) [with _Tp =3D long int]', inlined from 'static void std::allocator_traits >::deallocate(allocator_type&, pointer, size_type) [with _Tp =3D long int]'= at /software/GCCcore/12.2.0/include/c++/12.2.0/bits/alloc_traits.h:496:23, inlined from 'void std::_Vector_base<_Tp, _Alloc>::_M_deallocate(pointe= r, std::size_t) [with _Tp =3D long int; _Alloc =3D std::allocator]' = at /software/GCCcore/12.2.0/include/c++/12.2.0/bits/stl_vector.h:387:19, inlined from 'std::_Vector_base<_Tp, _Alloc>::~_Vector_base() [with _Tp= =3D long int; _Alloc =3D std::allocator]' at /software/GCCcore/12.2.0/include/c++/12.2.0/bits/stl_vector.h:366:15, inlined from 'std::vector<_Tp, _Alloc>::~vector() [with _Tp =3D long in= t; _Alloc =3D std::allocator]' at /software/GCCcore/12.2.0/include/c++/12.2.0/bits/stl_vector.h:733:7, inlined from 'virtual void dnnl::graph::impl::dnnl_impl::bn_folding_t::execute(const dnnl::stream&, co= nst std::unordered_map&) const' at /src/third_party/ideep/mkl-dnn/src/backend/dnnl/op_executable.hpp:1060:63: /software/GCCcore/12.2.0/include/c++/12.2.0/bits/new_allocator.h:158:26: er= ror: 'void operator delete(void*, std::size_t)' called on pointer '' wi= th nonzero offset [1, 9223372036854775800] [-Werror=3Dfree-nonheap-object] 158 | _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n)); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type, con= st void*) [with _Tp =3D long int]', inlined from 'static _Tp* std::allocator_traits >::allocate(allocator_type&, size_type) [with _Tp =3D long int]' at /software/GCCcore/12.2.0/include/c++/12.2.0/bits/alloc_traits.h:464:28, inlined from 'std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp =3D long= int; _Alloc =3D std::allocator]' at /software/GCCcore/12.2.0/include/c++/12.2.0/bits/stl_vector.h:378:33, inlined from 'void std::vector<_Tp, _Alloc>::_M_range_initialize(_ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator =3D const long int*; _Tp = =3D long int; _Alloc =3D std::allocator]' at /software/GCCcore/12.2.0/include/c++/12.2.0/bits/stl_vector.h:1687:25, inlined from 'std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator =3D const long = int*; =3D void; _Tp =3D long int; _Alloc =3D std::alloca= tor]' at /software/GCCcore/12.2.0/include/c++/12.2.0/bits/stl_vector.h:706= :23, inlined from 'dnnl::memory::dims dnnl::memory::desc::dims() const' at /src/third_party/ideep/mkl-dnn/third_party/oneDNN/include/oneapi/dnnl/dnnl.= hpp:2677:66, inlined from 'virtual void dnnl::graph::impl::dnnl_impl::bn_folding_t::execute(const dnnl::stream&, co= nst std::unordered_map&) const' at /src/third_party/ideep/mkl-dnn/src/backend/dnnl/op_executable.hpp:1060:63: /software/GCCcore/12.2.0/include/c++/12.2.0/bits/new_allocator.h:137:48: no= te: returned from 'void* operator new(std::size_t)' 137 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp))); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ Command used: g++ -O3 -march=3Dsapphirerapids -Wall -Werror -std=3Dgnu++17 = -c -o a.o pre.cpp Preprocessed source is attached (rather large, sorry) The bug does not show when using another optimization level or arch. E.g. `-march=3Dcooperlake` works.=