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

    <tr>
        <th>Summary</th>
        <td>
            subtraction of unsigned offset overflow false alarm at -O2 and -O3
        </td>
    </tr>

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

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

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

<pre>
    ```c
#include<stdio.h>
#include<stdint.h>

static int32_t a = 0xD7953644L;
static uint32_t b = 0x97812A3CL;

static int8_t  func_1(void)
{
    int32_t *c[4];
    int32_t j = 0xB7161AB6L;
    int i;
    for (i = 0; i < 4; i++)
      c[i] = &a;
p:
    --b;
    for (j = 0; (j != 20); j++)
    {
 uint32_t d = 0xE0C863CCL;
        uint64_t e = 0x95E2DE4BF748DC16LL;
 ++d;
        --e;
    }
    if (j)
        goto p;
 return a;
}

void main()
{
    func_1();
    printf("%d", b);
}
```
Hello, we are using clang to compile the above code in Ubuntu 22.04.3 LTS.
We found a case that there are discrepancies when compiling with llvmorg-14.0.6 at -O2 and -O3.
Is the discrepancy caused by infinite loop in the program? since the behavior is undefined before [P2809](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2809r0.html).
```
$ ../compiler-builds/llvmorg-14.0.6_build/bin/clang -fsanitize=undefined -fsanitize=address --rtlib=compiler-rt -g -lgcc_s -I/home/csmith/include/csmith-2.3.0 -O2 testcase.c -o exec

$ timeout 1s ./exec 2>exec.err
testcase.c:13:7: runtime error: subtraction of unsigned offset from 0x7ffe760240e0 overflowed to 0x7ffe760240f8 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior analysis/test960851-m.c:13:7 in AddressSanitizer:DEADLYSIGNAL ================================================================= ==351086==ERROR: AddressSanitizer: SEGV on unknown address 0x000041b58ab3 (pc 0x000041b58ab3 bp 0x7ffe76024190 sp 0x7ffe760240c8 T0) ==351086==The signal is caused by a READ memory access. AddressSanitizer:DEADLYSIGNAL AddressSanitizer: nested bug in the same thread, aborting.

$ ../compiler-builds/llvmorg-13.0.1_build/bin/clang -fsanitize=undefined -fsanitize=address --rtlib=compiler-rt -g -lgcc_s -I/home/csmith/include/csmith-2.3.0 -O2 testcase.c -o exec

$ timeout 1s ./exec 2>exec.err

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVlGPozYQ_jXOywhkbCDwkIckJNeT9nrV7l2re1oZY4i3YCPbbHb76ytDEpJtqntuIwT2eOYbzzfjcZi1slFCrFCyQUmxYIM7aLMqZcoXpa7eVyjF08MRLhBeI0Kl4u1QCUS31lVShwdEd_-yqNz16vi2jjnJQSpHybMDBogWgN-KZZ7QNI4fEN3cKA5nzfKkmS-ziKzpdtb8CJw9O4B6UPw5QiR71bJCJD-pLk82AHDZAyJrjpJNjJLignm9_nLyvFlGabTepA8ftUDeSGptAJFMTmaIbsAPtxCPQ0Q245PPBgDev0RJMZogkrILYI_oetYMgvKeq5fZ1TQjkRcQ7N3QDbzccTpTcaG4OgW6w9sspdvtbaD-51XT-NmBOGcj2ZFiF2_2yzgrtlH6cGUzOa3-ARIE4kaGlsUVnfUYwgd-ABrtNPSznRFuMApmoi4o09unHTomFSLZ_fRfKmQiaV7ojVSuHhcIIkk1frZQXuvN3s4HZJr-ItpWe-2jAGYEDFaqBnjLVANOA9ddL1sB7iCAlfpVANeVAKngezkoNwAhIY5DCg_fnsIJ8Q8BtR5UBQw4s96UOW9vJgeVtNyInikuhYXjQaiTE-_3KN0B2va106YJojjEYQrMQfCVAFMVBF_pyclnO25pBnsHzgYrKijfQapaKukEtFr3fq9etTe6MaxDdA9WKj6FVIoDe5XagLQwqErUUnkIUWsjACWb30iGc3_MSHZwrre-tskekf3xeAx1L1RgXRVq0yCyf3E8QmRvuWd_f2yIn1WaW0T2PeuF8QOCCfVzj2tweHBdi0ge3k0NIjGEISL7UxJMUA6yrTz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