[llvm-bugs] [Bug 37235] New: clang-cl fails with default member initializer outside member functions

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 25 06:35:15 PDT 2018


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

            Bug ID: 37235
           Summary: clang-cl fails with default member initializer outside
                    member functions
           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

Building a shared library with the following content fails:

    #pragma once

    #ifndef EXPORT
        #   if defined(DLL_BUILD)
        #       define EXPORT __declspec(dllexport)
        #   else // Being used in a non Engine dll build, but still a dll use,
so import
        #       define EXPORT __declspec(dllimport)
        #   endif
    #endif


    /// The rule that produces an input mapping
    class EXPORT A
    {
    public:

        struct EXPORT Value
        {
            int m_mem = 0;
        };

        template <class T>
        struct TypedValue : public Value
        {
        };

        struct EXPORT BoolValue : TypedValue<bool>
        {
        };
    };

With the following error:

    C:\dev\src\playground\cpp\shlib.cpp(24,32): error : default member
initializer for 'm_mem' needed within de finition of enclosing class 'A'
outside of member functions
[C:\dev\src\playground\cpp\clangcl\clangcllink.vcxproj]
          struct TypedValue : public Value
                                     ^
      C:\dev\src\playground\cpp\shlib.cpp(28,31):  note: in instantiation of
template class 'A::TypedValue<bool
      >' requested here
          struct EXPORT BoolValue : TypedValue<bool>
                                    ^
      C:\dev\src\playground\cpp\shlib.cpp(20,13):  note: default member
initializer declared here
              int m_mem = 0;
                  ^
      C:\dev\src\playground\cpp\shlib.cpp(28,12):  note: due to 'TypedValue'
being dllexported
          struct EXPORT BoolValue : TypedValue<bool>
                 ^
      C:\dev\src\playground\cpp\shlib.cpp(6,38):  note: expanded from macro
'EXPORT'
          #       define EXPORT __declspec(dllexport)
                                           ^
      1 warning and 1 error generated.

-- 
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/20180425/93ca3f92/attachment.html>


More information about the llvm-bugs mailing list