title: C++ : No warning for unused local constants with /W4 (MSVC)
body: <p><em>The following code was compiled with MSVC 19.29.30133.0</em></p>
  <p>Given the following c++ line in a function</p>
  <pre class="lang-cpp prettyprint-override"><code>int foo = 0;
  </code></pre>
  <p>If the variable isn't referenced, MSCV will give you the following warning: <code>warning C4189: 'foo': local variable is initialized but not referenced</code></p>
  <p>However, if <code>const</code> is added in front of it, the warning disappears.</p>
  <pre class="lang-cpp prettyprint-override"><code>const int foo = 0; // &lt;&lt;--This line yields no warning with MSVC 19.29.30133.0
  </code></pre>
  <p>But this unused variable should still be removed, isn't it?</p>
  <p>So why is it that MSVC gives no warning? Is it a bug, is there a specification for unused constants?</p>
  <p>minimal reproduction:</p>
  <pre class="lang-cpp prettyprint-override"><code>int main() {
      int a = 0;
      const int b = 0;
  
      return 0;
  }
  </code></pre>
  <p>output:</p>
  <pre><code>Starting build...
  cl.exe /Zi /EHsc /nologo /W4 /std:c++20 /Fe: F:\prog\INF1005C\tst\unused_constant.exe F:\prog\INF1005C\tst\unused_constant.cpp
  unused_constant.cpp
  
  F:\prog\INF1005C\tst\unused_constant.cpp(2): warning C4189: 'a': local variable is initialized but not referenced
  
  Build finished with warning(s).
  </code></pre>