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

    <tr>
        <th>Summary</th>
        <td>
            [clang] False positive clang-diagnostic-format with long format specifier on Windows
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          chrchr-github
      </td>
    </tr>
</table>

<pre>
    ~~~c++
#include <cstdio>

enum E : unsigned { E0, E1 };

int f(const char* c) {
    E e;
    return sscanf(c, "%lx", &e);
}
~~~
~~~
.\foo.cpp:7:29: warning: format specifies type 'unsigned long *' but the argument has type 'E *' [clang-diagnostic-format]
    7 |     return sscanf(c, "%lx", &e);
 |                       ~~~   ^~
      | %x
~~~
The warning goes away if `E`'s base type is `unsigned long`, but `long` types are also 32bit on Windows.
There also is no warning for e.g. a typeless enum and `%x`.
If the warning is (correctly) triggered by a size mismatch, this should be stated in the error message.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE-PvDYM_TTmYg2CsAzDgcP8lXqv1HMIBlKFZBSH3Z0e-OwVmX-_btVLESIO8fOznZdIZj1YogbKA5SnRM5hdL5Ro1ej3ww6jHObtK67NcuyKBCH9c1OkO1BFNoqM3eEUBwVh047KM6PxfglO094Rij2ONvI0yFUBzxnII54zhGqExSHXyHaBuxB7JSzHFCN0oPYowJRr8i7DyLiGemFXOeewuwtMitpI35lACFAlOY7jut0SyDqN2N1uhvLsvwwUiiPvXOpul6h2FdQ7FfcHr-kt9oOq9k7P8mAfCWle02M4XYlBFG9SjXODghiD6LCdg4YRkLph3kiG3CUb8T56QXlQRlph02n5WAdB602dx4oT-9iK4TqiP-37Bf438-yLIgI5Xl5k2H0B1F-_-jR7yM9-4GDI0b5JW-oe4RtdoZtBqJibCXTvU7N68I_mhOdjrE3sM0ef6I3o_SE0rDDQrQ6oLP4h7ad--L0xf700IzWvVLpnUdKhxRljGSIGaMQpe0wMpbfsM0eYX7r47Y8wWuSq_i8JxXMbZVd8HoYyFOH7Q0lsv6LcNI8yaDGNfswakYe3Ww6bAk5yEAdahvjkvfO40TMcqA06Zqiq4taJtTklajENi_yXTI2Wb3ri7zvdlRV20xuy1aRkF1VdXXWllmf6EZk4iOrRZlnH7til4qirBXlsu5L2SmVw0dGk9QmNeZzSp0fEs08U5NndV3WiZEtGY6HXIgosVUc5SnxzQrYtPPA8JEZzYHfIYIOJt4Md0R5wos0THh1rIP-JPwPseKXDuNd_j9Oif9lI5PZm2YM4cpQ7EFcQFzu902q3ATisqbxGDZX7_4kFUBcYlkM4vKo7LMRfwcAAP__AKVxkQ">