Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] Fix mismatched-new-delete warning in compression.hpp #17607

Conversation

AlexeySachkov
Copy link
Contributor

@AlexeySachkov AlexeySachkov commented Mar 24, 2025

Fixed the following warning when DPC++ is built in Release mode with gcc 13:

In member function 'void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = char]',
    inlined from 'std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = char; _Dp = std::default_delete<char>]' at /usr/include/c++/13/bits/unique_ptr.h:404:17,
    inlined from 'static std::unique_ptr<char> sycl::_V1::detail::ZSTDCompressor::DecompressBlob(const char*, size_t, size_t&)' at /tmp/llvm/sycl/source/detail/compression.hpp:139:3,
    inlined from 'void sycl::_V1::detail::CompressedRTDeviceBinaryImage::Decompress()' at /tmp/llvm/sycl/source/detail/device_binary_image.cpp:258:54:
/usr/include/c++/13/bits/unique_ptr.h:99:9: error: 'void operator delete(void*, std::size_t)' called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete]
   99 |         delete __ptr;
      |         ^~~~~~~~~~~~
In file included from /tmp/llvm/sycl/source/detail/device_binary_image.cpp:13:
In static member function 'static std::unique_ptr<char> sycl::_V1::detail::ZSTDCompressor::DecompressBlob(const char*, size_t, size_t&)',
    inlined from 'void sycl::_V1::detail::CompressedRTDeviceBinaryImage::Decompress()' at /tmp/llvm/sycl/source/detail/device_binary_image.cpp:258:54:
/tmp/llvm/sycl/source/detail/compression.hpp:119:66: note: returned from 'void* operator new [](std::size_t)'
  119 |     auto dstBuffer = std::unique_ptr<char>(new char[dstBufferSize]);

Found in:
#16463 (comment)

This is a cherry-pick of #16483

…16483)

Fixed the following warning when DPC++ is built in Release mode with gcc
13:

```
In member function 'void std::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = char]',
    inlined from 'std::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = char; _Dp = std::default_delete<char>]' at /usr/include/c++/13/bits/unique_ptr.h:404:17,
    inlined from 'static std::unique_ptr<char> sycl::_V1::detail::ZSTDCompressor::DecompressBlob(const char*, size_t, size_t&)' at /tmp/llvm/sycl/source/detail/compression.hpp:139:3,
    inlined from 'void sycl::_V1::detail::CompressedRTDeviceBinaryImage::Decompress()' at /tmp/llvm/sycl/source/detail/device_binary_image.cpp:258:54:
/usr/include/c++/13/bits/unique_ptr.h:99:9: error: 'void operator delete(void*, std::size_t)' called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete]
   99 |         delete __ptr;
      |         ^~~~~~~~~~~~
In file included from /tmp/llvm/sycl/source/detail/device_binary_image.cpp:13:
In static member function 'static std::unique_ptr<char> sycl::_V1::detail::ZSTDCompressor::DecompressBlob(const char*, size_t, size_t&)',
    inlined from 'void sycl::_V1::detail::CompressedRTDeviceBinaryImage::Decompress()' at /tmp/llvm/sycl/source/detail/device_binary_image.cpp:258:54:
/tmp/llvm/sycl/source/detail/compression.hpp:119:66: note: returned from 'void* operator new [](std::size_t)'
  119 |     auto dstBuffer = std::unique_ptr<char>(new char[dstBufferSize]);
```

Found in:
intel#16463 (comment)
@AlexeySachkov AlexeySachkov marked this pull request as ready for review March 24, 2025 17:11
@AlexeySachkov AlexeySachkov requested a review from a team as a code owner March 24, 2025 17:11
@AlexeySachkov
Copy link
Contributor Author

Pre-commit on sycl-rel branch isn't fully functional yet, but this change is mostly NFC and build on Linux has passed, so I will proceed with merge

@AlexeySachkov AlexeySachkov merged commit cba981a into intel:sycl-rel-6_1_0 Mar 25, 2025
7 of 13 checks passed
@AlexeySachkov AlexeySachkov deleted the private/asachkov/cherry-pick-16483 branch March 25, 2025 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants