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

    <tr>
        <th>Summary</th>
        <td>
            Clang applies UBSan without being asked to do so
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    I reproduced [this issue](https://github.com/google/sanitizers/issues/1595), compiling the following:

```c
#include <stdlib.h>
int main () {
    // unsigned char *buf[3];
    unsigned long buf[4];

    int stack_size = 10000;
    unsigned char *stack = (unsigned char *)calloc(10000, sizeof(int));


    // free(stack);
    return 0;
}
```

I used the flags `-g -O0 -fsanitize=address -fno-common -fno-omit-frame-pointer`.

I looked at the assembly in GDB and saw numerous calls that looked related to UBSan. I added the flag `-fno-sanitize=undefined` and the same instructions appeared in the resultant executable. I also explicitly added `-fsanitize=undefined` and diffed all three executables; they were all the same, all containing calls for UBSan. GCC does not apply UBsan when using these flags, which was the behavior I expected to happen. I cannot find documentation that says UBSan is bundled with ASan.

I am using Clang v15.0.6 from the Tumbleweed OSS repository.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VMGO27gS_Br60rAhUSPbOugwtt8Ec8phXs6LFtmSuEORBpscx_n6BSV7x0kWAQxLBItV1dViI7MZHFEr6oOoTytMcfShHd-VTy6G64Ru1Xl9bV8h0Dl4nRRpEPUhjobBMCcS9UnI_RjjmUX1LOSLkC-DiWPqNspPeeH9YEnIF0ZnovlBgYV8mc_ml7JuaiEbIY-g_HQ21rgB4kjQe2v9xbgh0xYnUdz_t8XyU7e1rIxTNmkCUR05amu6zSiq_y3bxkWY0DgQci9kA2J3WDYAABa7kNwcgwY1YgAhn7vUi_pQ5dqqB_i_OOvdAAvo6RH0Cc2yHFG9_8XmR3Z2grIoiuK_-e6684kZ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