<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Fail to report error when base class member shadows template parameter"
   href="https://llvm.org/bugs/show_bug.cgi?id=24806">24806</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Fail to report error when base class member shadows template parameter
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.7
          </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>writalnaie@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang does not report error when parent class member shadows derived template
class's template parameter. For example, the following code does not report any
error. 

===== begin of test.cpp =====

#include <stdio.h>

struct Base {
    int data;
    Base() : data(20) {}
};

template<int data>
struct Derived : public Base {
    void func() {
        printf("%s %d\n", __PRETTY_FUNCTION__, data);
    }
};

int main() {
    Derived<30>().func();
    return 0;
}

===== end of test.cpp =====
===== begin of output =====

$ ../clang-3.7 test.cpp  -Wall
$ ./a.out
void Derived<30>::func() [data = 30] 20

===== end of output ======

However, when the declaration of `int data` is moved to the body of Derived,
clang report the error of shadowing template parameter. Without report, it is
hard to diagnose the misbehavior of the program with the shadowing code.

By the way, it seems other compiler such as gcc also fail to report the error.</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>