[llvm-bugs] [Bug 31971] New: Compilation failure of template with dllexport and anonymous namespace

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 15 07:46:04 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=31971

            Bug ID: 31971
           Summary: Compilation failure of template with dllexport and
                    anonymous namespace
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eric at andante.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170215/42642c6d/attachment.html>


More information about the llvm-bugs mailing list