<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 - Compilation failure of template with dllexport and anonymous namespace"
   href="https://bugs.llvm.org/show_bug.cgi?id=31971">31971</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compilation failure of template with dllexport and anonymous namespace
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.9
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows XP
          </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++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>eric@andante.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This sample program:

template <class _Tp, class _Dp>
class __declspec(dllexport) foobar
{
  typedef _Tp element_type;
  typedef _Dp deleter_type;
 public:
  foobar();
  ~foobar();
};

class barfoo
{
 public:
  barfoo();
  ~barfoo();
};

namespace {
struct release
{
    void operator()(barfoo* p) {}
};
}

int main(int argc, char * argv[])
{
  foobar<barfoo,release> asdf;
}

fails to compile with the error:

l4.cpp:4:29: error: 'foobar<barfoo, (anonymous namespace)::release>' must have
external linkage when declared 'dllexport'
class __declspec(dllexport) foobar
                            ^
l4.cpp:29:26: note: in instantiation of template class 'foobar<barfoo,
(anonymous namespace)::release>' requested here
  foobar<barfoo,release> asdf;
                         ^
1 error generated.

Removing the "namespace" surrounding "struct release" cures the issue and makes
it possible to compile the test program.</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>