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

            Bug ID: 51661
           Summary: dllexported subclass causes implicit instantiation of
                    base class static fields
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]

The following code fails to build with clang-cl 14.0.0 (ee659383):

  // Define a template with a static field.
  template <typename T>
  struct Base {
    static int member;
  };

  // Define a dllexported subclass using the template.
  struct __declspec(dllexport) Sub: public Base<int> {};

  // Declare storage for the static member:
  template <>
  int __declspec(dllexport) Base<int>::member;

This fails with:

  test.cc(12,16): error: explicit specialization of 'member' after
instantiation
  int Base<int>::member;

  test.cc(4,16): note: implicit instantiation first required here
    static int member;

The same code builds with CL 19.29.30037, or if I remove the dllexport
declaration from `Sub`, or if I move the static member declaration above the
definition of `Sub`.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to