[llvm-bugs] [Bug 33570] 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 15:38:45 PDT 2017


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

Reid Kleckner <rnk at google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |REOPENED

--- Comment #2 from Reid Kleckner <rnk at google.com> ---
I had to revert this, because it broke code like this:

struct __declspec(dllimport) Foo {
  int a;
  int get_a() { return a; }
};
template <int (Foo::*Getter)()> struct HasValue {
  int operator()(Foo *p) { return (p->*Getter)(); }
};

int main() {
  Foo f;
  f.a = 3;
  int x = HasValue<&Foo::get_a>()(&f);
}

Clang would say:

t.cpp:12:20: error: non-type template argument of type 'int (Foo::*)()' is not
a constant expression
  int x = HasValue<&Foo::get_a>()(&f);
                   ^~~~~~~~~~~
t.cpp:5:22: note: template parameter is declared here
template <int (Foo::*Getter)()> struct HasValue {
                     ^
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/20170623/3a350ee3/attachment.html>


More information about the llvm-bugs mailing list