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

    <tr>
        <th>Summary</th>
        <td>
            [clang-cl] Macro definition depends on include order (without diagnostics)
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          andreas-0815-qwertz
      </td>
    </tr>
</table>

<pre>
    Using `clang-cl` the value of `_dummy` in the below program depends on the order of the two include directives:

```
#include <immintrin.h>
#include <Windows.h>

static const int dummy_ = _MM_HINT_T0;
```

Using clang-16 (via Powershell) like

`& 'C:\Program Files\LLVM\bin\clang-cl.exe' /Od /Z7 /Wall /WX /winsdkdir ms\sdk /vctoolsdir ms\crt -fuse-ld=lld /E redef_issue.cc`

(with Windows SDK and UCRT headers installed under the `ms` subdirectory) will result in `_dummy` having the value 1; switching the includes will result in the value 3.

Background is that  `_MM_HINT_T0` (as well as `_MM_HINT_T2`) are differently defined in clang's own `xmmintrin.h` and Windows SDK's `winnt.h`. As both files are found via paths specified with `-internal-isystem`, the macro redefinition is not diagnosed regardless of the include order.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsVF-P4jYQ_zTmZQQKDgnwkIdbONSqt-2pvetVfUFOPEmm69jU45DbfvrKBnbZ1UloQjL2eH5_PIqZOotYieJBFPuZGkPvfKWs9qh4nm2WxfzfCX34b1Y7_Vx9ZbIdiDJrjLLdvDGizCD0CGdlRgTXxtxRj8PwHDNkU7JG4yY4edd5NYDGE1rN4C5J5zX6uDO-hMkB2caMGkGTxybQGVnkH0S2F9ktltn1d3mV-W2LyHc0DGSDJ7voRf7xRyu-kdVu4vt8ihxUoAYaZzkA2QAJxhFEvofj4-Pxp59__XL8kon84cdtpHgh6MLOsgQhN2dS8NlN6LlHY4TcgqEnfI9HxrXrXURa7D5fmTqQQ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