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

    <tr>
        <th>Summary</th>
        <td>
            [clang][UBSan] Segfault with -fsanitize=vla-bound -ftrivial-auto-var-init=zero/pattern
        </td>
    </tr>

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

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

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

<pre>
    Just compile
int main(int argc, char **argv) {
  int x = -1;
  int arr[x];
  return 0;
}

with
`clang  -fsanitize=vla-bound -ftrivial-auto-var-init=zero`
or with
`clang  -fsanitize=vla-bound -ftrivial-auto-var-init=pattern`
Run the executable and see that UBSan rt catches segfault:
`UndefinedBehaviorSanitizer:DEADLYSIGNAL`
with
`clang -fsanitize=vla-bound -ftrivial-auto-var-init=uninitialized`
UBSan works fine and the process terminates with zero exit-code.

Observed in clang-17.0.6 and clang-18.1.3
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysU0-Pmz4Q_TTDZQTC5t9y4JD8-KVqtWqlRnvo0cAE3HVMZA9sdj99BUHpVuqlVS8wDOPn997MKO91b4kqyPaQ1YGaeBhd1Q7k2b4-D0Ezdq_Vp8kztuP5og1BXEO805bxrLQF-bCEyvUtyP-wHZRDkDuQO-X6GWSJUOxvRxCXyitCUmMoIPklrZyDbH-FrH73wxFPzmJ8T0FRb8H6fNE8bN953Bple8Tw5JXVrN8Ikno2KmzGyXYYntjpWSsTqonHcFYu1FYzJPUbuRHy-IYzOvwnoBfFTM7ecb9OFnkgpCu1E6vGECrboSdCHhTj0_6oLDrGVvHiPXrqT2oyDMnuTubJdnTSlro9DWrWoztupBwku_r_Xf347fjxw-fd4_3a32j5YymTXQKtjH6j7o58I_wyumePC6dVzqLw4saWvEcmd9ZWMfnVUVxsRrpqDtuxo-h9G780ntxMHWqLK8lQFFEc5SvmlniIRJQEXZV0ZVKqgCpRiEJkMsvyYKhIiORUpKkqRCNU1giRyyRJ86KLqSmFDHQlY5nGWSJEnJYij_KyE016OnXxUl4QpDGdlTaRMfM5Gl0faO8nqsqkTMvAqIaMX3dEypURSLmsi6uW-rCZeg9pbLRn_xOBNZt1sW4nshqy_eobZDUetwbf3Pm7qZWHbc6CyZlqYL74ZV7kAeSh1zxMTdSOZ5CHhdL2Ci9u_E4tgzysCj3Iw03kXMkfAQAA__9aJ0or">