<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/94741>94741</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            UBSAN failures in clang interpreter tests on 32 bit ARM
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DavidSpickett
      </td>
    </tr>
</table>

<pre>
    Doing a 32 bit Arm build with UBSAN enabled, I get many failures from the clang interpreter:
```
  Clang :: AST/Interp/arrays.cpp
  Clang :: AST/Interp/atomic.c
  Clang :: AST/Interp/atomic.cpp
  Clang :: AST/Interp/bitfields.cpp
  Clang :: AST/Interp/builtin-align-cxx.cpp
 Clang :: AST/Interp/builtin-functions.cpp
  Clang :: AST/Interp/builtins.cpp
  Clang :: AST/Interp/c.c
  Clang :: AST/Interp/c23.c
  Clang :: AST/Interp/comma.cpp
  Clang :: AST/Interp/complex.c
  Clang :: AST/Interp/complex.cpp
  Clang :: AST/Interp/cond.cpp
  Clang :: AST/Interp/const-eval.c
  Clang :: AST/Interp/const-fpfeatures.cpp
  Clang :: AST/Interp/constexpr-nqueens.cpp
  Clang :: AST/Interp/constexpr-subobj-initialization.cpp
  Clang :: AST/Interp/cxx03.cpp
  Clang :: AST/Interp/cxx11.cpp
  Clang :: AST/Interp/cxx17.cpp
  Clang :: AST/Interp/cxx20.cpp
  Clang :: AST/Interp/cxx23.cpp
  Clang :: AST/Interp/cxx98.cpp
  Clang :: AST/Interp/depth-limit.cpp
  Clang :: AST/Interp/enums-targets.cpp
 Clang :: AST/Interp/enums.cpp
  Clang :: AST/Interp/eval-order.cpp
 Clang :: AST/Interp/floats.cpp
  Clang :: AST/Interp/functions.cpp
 Clang :: AST/Interp/if.cpp
  Clang :: AST/Interp/intap.cpp
  Clang :: AST/Interp/invalid.cpp
  Clang :: AST/Interp/lambda.cpp
  Clang :: AST/Interp/lifetimes.cpp
  Clang :: AST/Interp/literals.cpp
  Clang :: AST/Interp/loops.cpp
  Clang :: AST/Interp/memberpointers.cpp
  Clang :: AST/Interp/nullable.cpp
  Clang :: AST/Interp/objc.mm
  Clang :: AST/Interp/opencl.cl
  Clang :: AST/Interp/pointer-addition.c
  Clang :: AST/Interp/records.cpp
  Clang :: AST/Interp/references.cpp
  Clang :: AST/Interp/shifts.cpp
  Clang :: AST/Interp/spaceship.cpp
  Clang :: AST/Interp/switch.cpp
  Clang :: AST/Interp/sycl.cpp
  Clang :: AST/Interp/unions.cpp
  Clang :: AST/Interp/vectors.cpp
  Clang :: AST/Interp/weak.cpp
```

Most of them are problems with reference binding or calling of constructors on misaligned addresses. Usually the type requires 8 byte alignment but the address is 4 byte aligned.

This has come up a lot recently, including https://github.com/llvm/llvm-project/pull/89811 which has "uncovered" this issue outside of UBSAN builds.

I think the assumptions in the interpreter's management of its virtual stack do not hold for 32 bit Arm. I don't know that that's the cause of all the issues we have seen without UBSAN, but it seems likely.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUl8tu4zoPx5_G2RAJbCWtm4UXnSkKdDHf4puZB5AlOuZUF49Epcl5-gMpc-m54EAGCjeJf6QokpL-kjHSySEOzd2H5u5pIxPPPgxP8kz680LqFZk3o9fX4cmTO4GEvYCRGB6DhTGR0fBGPMPXD58f_wfo5GhQN-IjvMAJGax0V5gkmRQwwhS8BZ4RlJHuBOQYwxKQMTT7x6Z9atrH5r798Ve-AnwsaH6_f4THz18a8fxS7BrxLEOQ17hTy1JFs7ekdmoNW-d5JJ4Ija4OJSeOyW2loZPbqsvlnWGN3ZScYvJu7YDVfGWalNhXgt5aWT24t4vBS7XnG1zr2-kVbOQtnqWpDSXz0zKh5Nzvq8bByxK27ntCXFGlX4YxjX78tiVHTNLQHzJ3R7Wby6Xdr4C7bg3cr4BFuwZeE_PxoRbWuPC8NWSJa03QJRu3LMMJOVYu5WJTPcBZmq0P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