<html>
    <head>
      <base href="http://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 --- - Clang in C++11 mode refuses to get address of templated function as template parameter"
   href="http://llvm.org/bugs/show_bug.cgi?id=17030">17030</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang in C++11 mode refuses to get address of templated function as template parameter
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.1
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>felixcca@yahoo.ca
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Apple's Clang that ships with Xcode 4.6.3 fails to parse the following program:

    template<void (*F)(void)>
    struct Func {};

    template<typename T>
    void foo();

    int main() {
        struct Bar {}; // function-local type
        Func<foo<Bar>> x;
    }

The error is the following, on the line that declares `x` in `main`:

<span class="quote">> error: non-template argument refers to function 'foo<Bar>' with internal linkage
> Func<foo<Bar>> x;
>      ^~~~~~~~</span >

I might be mistaken as I'm not very familiar with linkage, but this seems to
run afoul of n3242's ยง14.3.2:

<span class="quote">> A template-argument for a non-type, non-template template-parameter shall be one of:
> [...]
> - a constant expression (5.19) that designates the address of an object with static storage duration and external or internal linkage or __a function with external or internal linkage__, including function templates and function template-ids but excluding non-static class members [...]</span >

It also happens (according to this guy: <a href="http://stackoverflow.com/q/18498957/">http://stackoverflow.com/q/18498957/</a>)
with Clang 3.4 (trunk 187493), although in this case it says the function "has
no linkage" (which seems to be a better reason to refuse it).

G++ will gladly compile that code.

It should also be noted that this works with clang:

    template<typename T>
    void foo();

    int main() {
        struct Bar {}; // function-local type
        void (*y)() = foo<Bar>;
    }</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>