I found that ubsan will report an incorrect alignment for a type in case it is allocated with the global operator new (without alignment), if we have it return an offset ptr.
I wrote a small repro: https://godbolt.org/z/n8Yh8eoaE
The type is aligned on 8 bytes (verified by static_assert on its alignof), but ubsan reports: "constructor call on misaligned address 0x000002af8fd8 for type 'Param', which requires 16 byte alignment".
Now I suppose changing the ptr returned by new that way breaks the __STDCPP_DEFAULT_NEW_ALIGNMENT__, but in the specs in [basic.stc.dynamic.allocation] it says for the non-aligned, non array new:
Otherwise, the storage is aligned for any object that does not have new-extended alignment and is of the requested size
which is pretty vague.
I would either expect to get an error message to indicate that break, or nothing, because in the end the pointer returned by new is 8 bytes aligned, and matches the 8 bytes alignment requirement of the type.
I think the issue comes from this line:
Instead of the allocator alignment result.getAlignment(), it should be the type alignment allocAlign. I've tried it, and ran the tests, the error goes away and the tests pass.
I suggest simplifying this to CHECK-NOT: runtime error, since no errors are expected. This is mostly to improve test debuggability anyway, the test will fail if it exits non-zero.