<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - False-positive: -Wunused-variable warning triggers for non-instantiated class-template specialization"
   href="https://bugs.llvm.org/show_bug.cgi?id=46035">46035</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>False-positive: -Wunused-variable warning triggers for non-instantiated class-template specialization
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jbakam@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Small repro via CRTP:
```
template <typename T, bool B>
struct Base {
    void foo() {
        // no-op
    }
};

template <typename T>
struct Base<T, true> {
    void foo() {
        size_t var = 1; // <--- LoC for which the warning is issued for
    }
};

template <bool B>
struct Derived : public Base<Derived<B>, B> {
    void bar() {
        this->foo();
    }
};

Derived<false> d;
```
Compiling this code-excerpt with `clang++ -std=c++11 -Wall` results with
false-positive warning:
```
warning: unused variable 'var' [-Wunused-variable]
        size_t var = 1;
```

I've checked other combos like {C++11, C++14, C++17, C++2a} x {clang-6,
clang-7, clang-8, ... clang-trunk} and warning is still there.

Mind that one does not have to `Derived<false> d;` to get a warning (it's in
the example for clarity reasons) and in real-world scenario `size_t var = ...`
is being used in the very next line (in production-code).

Thanks,
Adi
Mind</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>