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

'new (std::nothrow) SomeType[sz]' not tracked by leak detector #1129

Closed
Digital-Monk opened this issue Nov 6, 2017 · 2 comments
Closed

'new (std::nothrow) SomeType[sz]' not tracked by leak detector #1129

Digital-Monk opened this issue Nov 6, 2017 · 2 comments

Comments

@Digital-Monk
Copy link

Digital-Monk commented Nov 6, 2017

During setup, allocate a buffer using the "nothrow" version of new:

pBuf = new (std::nothrow) uint8_t[1024];

During teardown, delete[] that buffer:

delete[] pBuf;

Your test body can be empty, and the setup/teardown functions can contain only those lines. This eliminates any possibility of memory leak/corruption other than in the framework.

You'll get a "Deallocating non-allocated memory" error when the test runs, because the memory leak detector didn't see the allocation by the specialized (std::nothrow) form. If you remove (std::nothrow) from the example, it will work. I have not tested this for single objects, but suspect that it exists there as well.

@Digital-Monk
Copy link
Author

I just noticed some lines in the output of my ./configure run relating the to (non-)throwing versions of new and delete, so it is entirely possible that this is an artifact of what ./configure discovered in my toolchain. If so, this probably isn't a bug so much as a confusing situation that might be usefully addressed in a FAQ or Troubleshooting page.

@basvodde
Copy link
Member

Ok, thanks. Closed it then.

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

No branches or pull requests

2 participants