Created attachment 46344 [details] Preprocessed testcase The following results in an UBSan error: #include <memory_resource> int main(void) { auto * const mem = std::pmr::new_delete_resource()->allocate(10); } compiled with g++-9 pmr_san.cpp -fsanitize=undefined -std=c++17 -o pmr_san results in ../gcc-9/pmr_san2.cpp:4:63: runtime error: member call on address 0x00010752d440 which does not point to an object of type 'memory_resource' 0x00010752d440: note: object is of type '*NSt3pmr12_GLOBAL__N_112newdel_res_tE' 01 00 00 00 c8 7e 51 07 01 00 00 00 00 00 00 00 00 00 00 00 e0 ee 50 07 01 00 00 00 98 ee 50 07 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for '*NSt3pmr12_GLOBAL__N_112newdel_res_tE' /usr/local/Cellar/gcc/9.1.0/include/c++/9.1.0/memory_resource:99:25: runtime error: member call on address 0x00010752d440 which does not point to an object of type 'memory_resource' 0x00010752d440: note: object is of type '*NSt3pmr12_GLOBAL__N_112newdel_res_tE' 01 00 00 00 c8 7e 51 07 01 00 00 00 00 00 00 00 00 00 00 00 e0 ee 50 07 01 00 00 00 98 ee 50 07 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for '*NSt3pmr12_GLOBAL__N_112newdel_res_tE' I am not sure whether this is a libstdc++ or UBSan bug (or if I am doing something wrong). I am attaching a preprocessed version too. This looks similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80963, triggered by Boost implementation of PMR.
The type new_del_res_t is derived from memory_resource, so this is a false positive. UBsan can't see the truth, because src/c++17/memory_resource.o in libstdc++.so is not compiled with -fsanitize=undefined.