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

    <tr>
        <th>Summary</th>
        <td>
            The -Wformat=2 flag should enable all -Wformat diagnostics similar to GCC
        </td>
    </tr>

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

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

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

<pre>
    The behavior between `-Wformat=2` flag in Clang and GCC differ in a way which may cause users to inadvertently miss out on wanted diagnostics messages:
- In GCC, the `-Wformat=2` flag [is equivalent to](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wformat_003d2) `-Wformat -Wformat-nonliteral -Wformat-security -Wformat-y2k`.
- In Clang, `-Wformat=2` [is equivalent to](https://github.com/llvm/llvm-project/blob/680c780a367bfe1c0cdf786250fd7f565ef6d23d/clang/include/clang/Basic/DiagnosticGroups.td#L987) `-Wformat-nonliteral -Wformat-security -Wformat-y2k` 

While `-Wformat` in Clang includes the same diagnostics as `-Wformat=2` the difference in the behavior of `-Wformat=2` between the compilers [makes it problematic to make recommendations on the use of warning flags](https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++#enable-additional-format-function-warnings) that would be consistent between Clang and GCC as `-Wformat` provides a superset of diagnostics in Clang, but `-Wformat=2` provides the superset of diagnostics in GCC.

Consequently it would be better if the behavior of `-Wformat=2` in Clang could be changed to also include the diagnostics flags implied by `-Wformat`.

Link to a test case in Compiler Explorer that demonstrates the difference in behavior with the different combinations of options: https://godbolt.org/z/nvocaaehY
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUlU2P4zYMhn-NciEcOHKcj0MOO55mWmCBXgoseipoiYrVlaWsKCeb_vpCzvdgFtgFgiSgbYp834c0MtudJ9qI-kXUrxMcUhfiJnWhR_anHv2kDfq0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