https://github.com/rjmccall commented:

So this is interesting, because I agree that the diagnostic message is 
misleading, but I'm not sure this is the right solution.

The replaceable global `operator new` functions are required to return a 
pointer that's appropriately aligned to some target-specific value. In the 
user's test case, they're running on x86_64 Linux, where that value is 16. So 
they do actually have an invalid implementation of `operator new`. And I'm 
pretty sure we do in fact emit code and optimize based on the assumption that 
the pointer has this target-specific alignment, even if the allocated type has 
a lower alignment requirement than that. So this change — which IIUC actually 
changes UBSan to only check for the type's actual alignment — seems pretty 
problematic.

Now, the diagnostic message is misleading because it's claiming that the type 
requires 16-byte alignment when it doesn't, but the narrow fix to that is to 
improve the diagnostic to talk about the requirements on global `operator new` 
when `allocationAlign` is greater than `allocAlign`, not to weaken the check.

https://github.com/llvm/llvm-project/pull/152532
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to