[llvm-bugs] [Bug 38109] New: Explicit specialization after instantiation error

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 9 11:12:13 PDT 2018


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

            Bug ID: 38109
           Summary: Explicit specialization after instantiation error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: steveire at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Clang does not accept code which CL.exe accepts. The example works if I remove
the dllexport.



C:\dev\src\playground\cpp>C:\dev\src\llvm\build\releaseprefix\msbuild-bin\cl.exe
explicit_instantiation.cpp
explicit_instantiation.cpp
explicit_instantiation.cpp(12,21):  error: explicit specialization of 's_foo'
after instantiation
template<> B* A<B>::s_foo = nullptr;
                    ^
explicit_instantiation.cpp(5,15):  note: implicit instantiation first required
here
    static T* s_foo;
              ^
1 error generated.

C:\dev\src\playground\cpp>cl.exe explicit_instantiation.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.14.26430 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

explicit_instantiation.cpp
Microsoft (R) Incremental Linker Version 14.14.26430.0
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:explicit_instantiation.exe
explicit_instantiation.obj
   Creating library explicit_instantiation.lib and object
explicit_instantiation.exp

C:\dev\src\playground\cpp>type explicit_instantiation.cpp

template <typename T>
class A
{
    static T* s_foo;
};

class __declspec(dllexport) B : public A<B>
{
};

template<> B* A<B>::s_foo = nullptr;

int main()
{
    return 0;
}

-- 
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/20180709/e21a0ee6/attachment.html>


More information about the llvm-bugs mailing list