[llvm-bugs] [Bug 33570] New: Clang incorrectly considers dllimport pointers to member functions to be valid constant initializers

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 23 10:34:43 PDT 2017


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

            Bug ID: 33570
           Summary: Clang incorrectly considers dllimport pointers to
                    member functions to be valid constant initializers
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: rnk at google.com
                CC: llvm-bugs at lists.llvm.org

Consider:

struct __declspec(dllimport) Foo { void f(); };
auto global_fp = &Foo::f;

This generates the following LLVM IR global:

declare dllimport void @"\01?f at Foo@@QEAAXXZ"(%struct.Foo*) #0
@"\01?global_fp@@3P8Foo@@EAAXXZEQ1@" = global i8* bitcast (void (%struct.Foo*)*
@"\01?f at Foo@@QEAAXXZ" to i8*), align 8

This means that 'global_fp' will contain the import thunk for Foo::f, and not
the actual address of Foo::f in the DLL that exports it.

This is basically another instance of
https://bugs.llvm.org//show_bug.cgi?id=20130.

The solution is to teach Sema that a dllimported member function pointer is not
constant, and to emit a dynamic initializer instead.

-- 
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/20170623/19250c3b/attachment-0001.html>


More information about the llvm-bugs mailing list