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

    <tr>
        <th>Summary</th>
        <td>
            bogus -Wconstant-logical-operand warnings with -std=gnu2x
        </td>
    </tr>

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

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

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

<pre>
    Building the Linux kernel with clang -std=gnu2x produces a large number of -Wconstant-logical-operand warnings that do not show up with 'gcc -std=gnu2x' or 'clang -std=gnu17'.

A lot of these come from a construct used in the kernel to check for the presence of a macro as a constant expression:

```
#define __take_second_arg(__ignored, val, ...) val
#define __ARG_PLACEHOLDER_1 0,
#define __is_defined(x) ___is_defined(x)
#define ___is_defined(val) ____is_defined(__ARG_PLACEHOLDER_##val)
#define ____is_defined(arg1_or_junk)    __take_second_arg(arg1_or_junk 1, 0)
```

which allows writing code like ``if (__is_defined(__KERNEL__))`` in place of a preprocessor ``#ifdef``. While the compiler warning correctly points out that an operand evaluates to a constant and can be omitted, this is not a practical advice, and it is not clear why this warning only gets produced for gnu2x but not older versions.
See also https://godbolt.org/z/53zezMW3E for a reproducer.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE1v6zgM_DXKhYhhy0lcH3zIa5NdYLsf6B56NGSJsfWiiIYkJ21__UJyg9e0PSwQ2JFEDkf0DIX3ureIDVv_YOuHhZjCQK4Rzqpu0ZF6bX5M2ihtewgDwqO20wsc0Vk0cNFhAGmE7WHpg2LlQ28n_gKjIzVJ9CDACNcj2OnUoQM6wPJZkvVB2LA01GspzJJGdMIquAhnte09hEEEUASWAviBLjCNcynGq17Km1qMV0AunnzmUVSMVxnLH1i-nZ9bMBQiiTCgR5B0Qjg4OoGARMpNMsDkUYG26bLv1wwEckB5hAO5tD869GglRiwBJyEdgfBXGGED4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