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

    <tr>
        <th>Summary</th>
        <td>
            [CSA] False negative: division by zero missed after introducing a Boolean temporary
        </td>
    </tr>

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

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

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

<pre>
    Hi, I found a false negative regarding the checker `core.DivideZero`.

Clang Static Analyzer misses a division by zero when the condition is stored in a Boolean temporary.

```cpp
int f(bool b) {
  bool condition = (b && b || b && b);
  int y = condition ? 0 : 1;
  return 1 / y;
}
```

## Actual result

The analyzer does not report `core.DivideZero`. Replacing the first two statements with the following produces the warning:

```cpp
int y = (b && b || b && b) ? 0 : 1;
```

## Expected result

The analyzer should report division by zero in both forms.

## Verification

The issue was reproduced with:

```sh
clang++ --analyze -Xclang -analyzer-checker=core.DivideZero bool_temporary.cpp
```

Version: Clang 24.0.0git (`1cb7e838cd47`)

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMVMGu4zYM_BrmQsSQpcR-PvjgJA3aa7dYFL0Uskzb6iqSIclJs19fyE6Q3X37gAIBAlDkmDNDUoagB0tUw_4A-9NGznF0vr5I_yXqm_06SrdpXXevf9XAj_gb9m62HUrspQmElgYZ9ZXQ0yB9p-2AcSRUI6kv5BEKppyn7KSvuqO_yDsoWAasAdYcjbQDfooyaoWNleb-lTxedAgUUGKnrzpoZ7G941fyDm8j2RXc2U7H9KQDhug8dagtSjw4Z0hajHSZnJf-_vgSFGz9qWkC1mgbsQf-1jpnsAVeIZQHYA3iEnnBgzhhykPgBfACW4TyCOURXxHgFYi1OMHel5pvEc7IEESD-TPNU5y9xRyBn_G-RqE8fdvmo2sugAtsVJylQU9hNnF9-WMklE_BOkcBrYvoaXI-fiA5_k6TkerpT699iBhvDkOUkS5kY8CbjuP66oxxt5Q7edfNisISvklvtR1ANB_Kev-fmr0X5ufkf_l3IhWp-5h-GN1suif5d0OjLbYujtg7fwnZd9ifyeteK5mMegHrEOZENSTIlX23KPOedhiBNSpNMfAD8ANut4-2cPvnEsdnwG8fGwHi9IM7y9D9_RrZVcwf5PhMPtFKeq1rw3cZy9igYxIbCpartqQ38aa6XZmqeAWs2XS16CpRyQ3VeVmxoiryim_GWu7kW1swJQvJ21wx2cu-KitVkCC1F91G15zxglW8yveiEDzb52Jf7gSVe8VyygXsGF2kNpkx10vm_LBZhKs5L8Wu2hjZkgnPm-LrlLVt5yHAjhkdYnjVRR3Ncn2OnxrYn_D83V1JjN-ZutyIDmUfyae1W2xK4_qTE7CZvanHGKeQDORn4OdBx3FuM-UuwM-pj8ffdvLuH1IR-HkhE4CfH3yuNf8vAAD___wSmrY">