public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "alexander.grund@tu-dresden.de" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-112370-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112370 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=sapphirerapids`: In file included from /software/GCCcore/12.2.0/include/c++/12.2.0/x86_64-pc-linux-gnu/bits/c++allocator.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_type) [with _Tp = long int]', inlined from 'static void std::allocator_traits<std::allocator<_Tp1> >::deallocate(allocator_type&, pointer, size_type) [with _Tp = 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(pointer, std::size_t) [with _Tp = long int; _Alloc = std::allocator<long int>]' 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 = long int; _Alloc = std::allocator<long int>]' 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 = long int; _Alloc = std::allocator<long int>]' 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&, const std::unordered_map<int, dnnl::memory>&) 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: error: 'void operator delete(void*, std::size_t)' called on pointer '<unknown>' with nonzero offset [1, 9223372036854775800] [-Werror=free-nonheap-object] 158 | _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n)); | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = long int]', inlined from 'static _Tp* std::allocator_traits<std::allocator<_Tp1> >::allocate(allocator_type&, size_type) [with _Tp = 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 = long int; _Alloc = std::allocator<long int>]' 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 = const long int*; _Tp = long int; _Alloc = std::allocator<long int>]' 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 = const long int*; <template-parameter-2-2> = void; _Tp = long int; _Alloc = std::allocator<long int>]' 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&, const std::unordered_map<int, dnnl::memory>&) 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: note: returned from 'void* operator new(std::size_t)' 137 | return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp))); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ Command used: g++ -O3 -march=sapphirerapids -Wall -Werror -std=gnu++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=cooperlake` works.
next reply other threads:[~2023-11-03 15:13 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-03 15:13 alexander.grund@tu-dresden.de [this message] 2023-11-03 15:32 ` [Bug c++/112370] " alexander.grund@tu-dresden.de 2023-11-06 8:14 ` [Bug tree-optimization/112370] " alexander.grund@tu-dresden.de 2023-11-06 8:15 ` alexander.grund@tu-dresden.de
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-112370-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).