[llvm-bugs] [Bug 24291] clang-cl imports an incorrect data symbol for dllimported classes inside a namespace with a default ctor which have a local static member

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Feb 7 19:32:27 PST 2016


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

Ehsan Akhgari [:ehsan] <ehsan at mozilla.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |---
            Summary|clang-cl doesn't respect    |clang-cl imports an
                   |noinline on methods of      |incorrect data symbol for
                   |dllimported classes         |dllimported classes inside
                   |                            |a namespace with a default
                   |                            |ctor which have a local
                   |                            |static member

--- Comment #8 from Ehsan Akhgari [:ehsan] <ehsan at mozilla.com> ---
It turns out that the test case in comment 0 was completely wrong, sorry for
the red herring.  Here is a minimized test case that demonstrates the
difference between cl and clang-cl:

$ cat test.cpp
namespace foo {

class __declspec(dllimport) S {
public:
  static S* Instance() {
    static S s;
    return &s;
  }
  S() {}
};

}

void use() {
  foo::S::Instance();
}

$ clang-cl -c -O1 test.cpp && llvm-nm test.obj
00000000 T ?use@@YAXXZ
00000001 a @feat.00
         U __imp_??_B?1??Instance at S@foo@@SAPAV12 at XZ@51

$ cl -nologo -c -O1 test.cpp && llvm-nm test.obj
test.cpp
00000000 T ?use@@YAXXZ
00e1797d a @comp.id
80000191 a @feat.00
         U __imp_?Instance at S@foo@@SAPAV12 at XZ


Note that if you drop the default ctor from S, or move S to the global
namespace, the bug goes away!

-- 
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/20160208/226da880/attachment.html>


More information about the llvm-bugs mailing list