https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103162
Bug ID: 103162 Summary: overconstrained std::pmr::memory_resource allocate/deallocate methods Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: florin.iucha at amd dot com Target Milestone: --- std::pmr::memory_resource::allocate() is annotated with __attribute__((__returns_nonnull__)) and std::pmr::memory_resource::deallocate() is annotated with __attribute__((__nonnull__)) . Looking at https://en.cppreference.com/w/cpp/memory/memory_resource/allocate it is not clear why the annotation is required. I have implemented several specialized memory resources, which sometimes can be used to manage pools in CPU space, sometimes from pools in other memory spaces, where allocating from 0 is perfectly acceptable. Checking https://eel.is/c++draft/mem.res.class, there's no mention of "null" in the context of allocate/deallocate . This attribute can be helpful to catch bugs in specialized memory resources in general, but specifically in my case it is tripping the address sanitizer when I'm returning null.