<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 --- - Poor diagnostic when forgetting to repeat default template type parameter"
   href="https://llvm.org/bugs/show_bug.cgi?id=25977">25977</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Poor diagnostic when forgetting to repeat default template type parameter
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Consider this program:

template<typename T> struct DefaultTraits;
template<typename T, typename Traits = DefaultTraits<T>>
struct ScopedTypeRef {
  ScopedTypeRef(T object = Traits::InvalidValue()) {}
};

template <typename NST>
struct PointerTraits {
  static NST InvalidValue() { return nullptr; }
};

template <typename NST>
class scoped_nsprotocol : public ScopedTypeRef<NST, PointerTraits<NST>> {
 public:
  using ScopedTypeRef<NST>::ScopedTypeRef;
};

int main() {
  scoped_nsprotocol<int*> array(new int);
}

clang complains:

thakis@thakis:~/Downloads$ ~/src/llvm-build/bin/clang -c
templated-inherited-ctor.cc  -std=c++11 
templated-inherited-ctor.cc:15:9: error: using declaration refers into
'ScopedTypeRef<int *>::', which is not a base class of
      'scoped_nsprotocol<int *>'
  using ScopedTypeRef<NST>::ScopedTypeRef;
        ^~~~~~~~~~~~~~~~~~~~
templated-inherited-ctor.cc:19:27: note: in instantiation of template class
'scoped_nsprotocol<int *>' requested here
  scoped_nsprotocol<int*> array(new int);
                          ^
templated-inherited-ctor.cc:19:27: error: no matching constructor for
initialization of 'scoped_nsprotocol<int *>'
  scoped_nsprotocol<int*> array(new int);
                          ^     ~~~~~~~
templated-inherited-ctor.cc:13:7: note: candidate constructor (the implicit
copy constructor) not viable: no known conversion from
      'int *' to 'const scoped_nsprotocol<int *>' for 1st argument
class scoped_nsprotocol : public ScopedTypeRef<NST, PointerTraits<NST>> {
      ^
templated-inherited-ctor.cc:13:7: note: candidate constructor (the implicit
move constructor) not viable: no known conversion from
      'int *' to 'scoped_nsprotocol<int *>' for 1st argument
class scoped_nsprotocol : public ScopedTypeRef<NST, PointerTraits<NST>> {
      ^
templated-inherited-ctor.cc:13:7: note: candidate constructor (the implicit
default constructor) not viable: requires 0 arguments,
      but 1 was provided
2 errors generated.


The fix is to change
  using ScopedTypeRef<NST>::ScopedTypeRef;
into
  using ScopedTypeRef<NST, PointerTraits<NST>>::ScopedTypeRef;
which isn't very clear from the error. If the base class is a template with
some default args and the default args are not explicitly passed in, then we
could emit a better diagnostic in that case.</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>