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

Fix clang-tidy error: clang-analyzer-cplusplus.NewDelete #1539

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yh-sb
Copy link

@yh-sb yh-sb commented Oct 5, 2024

It occurs when arg is used later after delete arg;. clang-tidy doesn't understand that there is an exception thrown after delete.

It leads to the following clang-tidy errors in the main project:

...\include\boost/asio/detail/impl/win_thread.ipp:79:20: error: Use of memory after it is freed [clang-analyzer-cplusplus.NewDelete,-warnings-as-errors]
   79 | arg->exit_event_ = exit_event_ = ::CreateEventW(0, true, false, 0);
      |                                ^

...\include\boost/asio/detail/impl/win_thread.ipp:90:38: error: Use of memory after it is freed [clang-analyzer-cplusplus.NewDelete,-warnings-as-errors]
   90 |   thread_ = reinterpret_cast<HANDLE>(::_beginthreadex(0,
      |                                      ^

It occurs when arg is used after delete. clang-tidy doesn't understand that there is an exception thrown after delete.

win_thread.ipp:79:20: error: Use of memory after it is freed [clang-analyzer-cplusplus.NewDelete,-warnings-as-errors]
   79 | arg->exit_event_ = exit_event_ = ::CreateEventW(0, true, false, 0);
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.

1 participant