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

    <tr>
        <th>Summary</th>
        <td>
            -Wunused-variable false positive in `if constexpr` and with `assert`
        </td>
    </tr>

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

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

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

<pre>
    Consider following minimal example:
```
#ifdef DEBUG
constexpr bool _debug_ = true;
#undef NDEBUG
#else
constexpr bool _debug_ = false;
#define NDEBUG
#endif

void f()
{
    if constexpr (_debug_) {
        const int cnt = 1;
        assert(cnt == 0);
    }  
}
```

`clang++ -c <file> -std=c++17 -Wunused-variable` yields `unused variable 'cnt'`.

`clang++ -c <file> -std=c++17 -Wunused-variable -DDEBUG` does not.

I suppose that this is unintended behavior.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytUsFunDAQ_Rq4jEBes8DugUM2JFUvPbXqMTJ4DK6MTbHZJH_fgWWTjVKpl1qDsWee3zzPuHHytbp31muJEyhnjHvWtoNBWz0IA_gihtFglN1FrI7YXVSwzS5bnmklUUH9cPrx5eJriS3gyzhB45yBJ4nN3D1BlNUQppmoTm9nZ7uc_XZzmJxoPP6TSYkFdUNFRNriJy4rtdp263x2WoKK-CHix81fbiRAQyt4T0qoLSWB4QNuGSsQtA3Q0reI2r0JumKE9zgFItogC4otqW-BUVnTtImp_17nq7M1wnYRP5FB0hLlvdJLex4g8UESfXsJ7kpIfs529iiTs5i0aAhVMHjVaKQHWl6CcA3SbUsSSTPF0v-YFZL60hPKLh16sC584P8Kfh5H5xFCLwJN2gPZbKm01D_S2GAvztpNaSyrTB6zo4iDDgarz8nWdwHEpoM-I3VnueptVxcZwkp41qFfYluHChbPk6n6EEa_PHb-SNYRZm7S1g20MeZ8_SXj5H5hS8V61N7P6GmR54eMx33FGnbIuWqPJTLWcLErmFL7tiyyUh2zwz42oqEXXkU5FYxbfIaVgtZRXse64oxzVjC-y1i-y1N-2DWZzHPMRX4QCqM9w0Foky46Ujd18VStkuiZegoa7YN_D9LtdGcR13TEL-bQu6n67gbxW8Rr5mpV_gfMGzEl">