Page MenuHomePhabricator

[analyzer] NFC: Fix nothrow operator new definition in a test.

Authored by NoQ on Dec 19 2017, 11:44 AM.



Fun C++ fact: definition

void *operator new(std::size_t size, std::nothrow_t &nothrow) throw() { ... }

does not override the global nothrow operator new. The standard nothrow operator new would still be called when this definition is present. Because, well, the second parameter (std::nothrow_t &nothrow) is missing a const qualifier, so it's a completely different function. In fact, temporary of type std::nothrow_t would never be bound to a non-const reference at all. So the custom operator defined above is also very hard to call.

This patch fixes the test case. The analyzer behavior is intended (at least for now, see also discussion in D41406) regardless of whether the operator is overridden correctly or not, but tests now actually test it.

Diff Detail


Event Timeline

NoQ created this revision.Dec 19 2017, 11:44 AM
a.sidorin accepted this revision.Dec 20 2017, 3:42 AM

Looks good, just a minor nit.

7 ↗(On Diff #127580)

Double negation can be simplified a bit: #if !LEAKS || ALLOCATOR_INLINING

This revision is now accepted and ready to land.Dec 20 2017, 3:42 AM
NoQ added inline comments.Dec 20 2017, 11:23 AM
7 ↗(On Diff #127580)

The rest of the #ifs in this file look like #if LEAKS && !ALLOCATOR_INLINING, so i wanted this to look similarly.

LGTM as well.

xazax.hun accepted this revision.Jan 9 2018, 5:52 AM
This revision was automatically updated to reflect the committed changes.