[clang] [compiler-rt] [UBSan] Fix incorrect alignment reported when global new returns an o… (PR #152532)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 1 08:33:47 PDT 2025


gbMattN wrote:

The ubsan handler for misaligned pointers contains data saying what type of check caught the misalignment. One type of check is on the constructor call, which is the check type which catches this issue with operator new.
In theory, could we check for this and print out a note with extra information after the main diagnostic? Something like
```
//constructor call
    if(Data->TypeCheckKind == 5){
      Printf(
        "\tNote: The default alignment of your architecture is %lu. Possible invalid alignment from an overloaded operator new?\n",
        __STDCPP_DEFAULT_NEW_ALIGNMENT__
      );
    }
```
Thoughts?

https://github.com/llvm/llvm-project/pull/152532


More information about the llvm-commits mailing list