<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 - Unhelpful diagnostic "qualified reference to 'A' is a constructor name rather than a type in this context""
   href="https://bugs.llvm.org/show_bug.cgi?id=43733">43733</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Unhelpful diagnostic "qualified reference to 'A' is a constructor name rather than a type in this context"
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>arthur.j.odwyer@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://godbolt.org/z/Wy8vGG">https://godbolt.org/z/Wy8vGG</a>

A newbie (not me originally) wrote this:

    template<class K>
    bool foo(const K& a, const K& b) {
        return std::less<K>::less()(a, b);
    }
    int i = foo(1,2);

Compiler complains:

    <source>:5:16: error: missing 'typename' prior to
    dependent type name 'std::less<int>::less'
        return std::less<K>::less()(a, b);
               ^~~~~~~~~~~~~~~~~~

Easy peasy. Seen this error message before. Explain to newbie that they need
`typename` here (and why). Add `typename` and recompile. Compiler *still
complains!*

    <source>:5:39: warning: ISO C++ specifies that
    qualified reference to 'less' is a constructor name
    rather than a type in this context,
    despite preceding 'typename' keyword [-Winjected-class-name]
        return typename std::less<K>::less()(a, b);
                                      ^

Now this is confusing. Complains with typename, complains without typename. I
had to go to Slack and ask what was supposed to be happening here.

What the compiler should say in this second case is not just a dry note about
the standardese names for things, but specifically something that would help
the user find and fix their bug. For example:

    hypothetical error: qualified reference to 'less' names
    a constructor, not a type,
    despite preceding 'typename' keyword [-Winjected-class-name]
        return typename std::less<K>::less()(a, b);
                                      ^~~~
    hypothetical note: to construct an object of this type,
    remove the explicit constructor name
        return typename std::less<K>::less()(a, b);
               ^~~~~~~~~            ~~~~~~

And in the preceding case, where adding `typename` was precisely the wrong
"fix," Clang really should not have suggested it.

    hypothetical error: qualified reference to 'less' names
    a constructor [-Winjected-class-name]
        return std::less<K>::less()(a, b);
               ^~~~~~~~~~~~~~~~~~

    hypothetical note: to construct an object of this type,
    remove the explicit constructor name
        return std::less<K>::less()(a, b);
                           ^~~~~~</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>