[llvm-bugs] [Bug 42784] New: Compilation error on Windows due to Microsoft export rules

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 26 11:43:40 PDT 2019


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

            Bug ID: 42784
           Summary: Compilation error on Windows due to Microsoft export
                    rules
           Product: libraries
           Version: 7.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: ravi.kappiyoor at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

This is more of an enhancement request than a bug (the bug is in Microsoft
export standards)...

The following code compiles correctly with clang++ on Linux. Under Windows, it
fails with an error message that the dynamic_cast failed because "D *" is not a
valid class name.

#include <list>
#include <type_traits>
class A {};

class B : public A
{
public:
  std::list<A *> _a;
};

class D : public A {};

template <class T>
class C : public B
{
  static_assert(std::is_base_of<A, T>::value, "T must inherit from A!");

  T * const * func() const
  {
    return dynamic_cast<T * const *>(_a.empty() ? nullptr : &(*_a.cbegin()));
  }
};

template <class T>
class E : public C<T> {};

class __declspec(dllexport) F : public E<D> {};

We get the same output when compiling this on Windows with any modern compiler
- Intel, Clang++, or MSVC (hence the remark about the issue being with
Microsoft export requirements instead of with Clang++). However, Intel has a
custom flag that they have provided us in the past
(/Qoption,cpp,--suppress_base_class_export) that allows this code to compile
normally. The enhancement request, then, is: Can Clang++ please have a similar
flag for this, too?

-- 
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/20190726/f3ded305/attachment-0001.html>


More information about the llvm-bugs mailing list