Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

C++ standard violation: [templates][explicit instantiation][access checking][pointer to overloaded member function] #34620

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR35647
Status NEW
Importance P normal
Reported by Gábor Márton (martongabesz@gmail.com)
Reported on 2017-12-12 13:18:00 -0800
Last modified on 2017-12-12 13:28:52 -0800
Version unspecified
Hardware All All
CC dgregor@apple.com, llvm-bugs@lists.llvm.org, martongabesz@gmail.com
Fixed by commit(s)
Attachments test.cpp (439 bytes, text/plain)
Blocks
Blocked by
See also
C++11 Standard / 14.7.2 (Explicit instantiation) / 12:
The usual access checking rules do not apply to names used to specify explicit
instantiations. [Note: In particular, the template arguments and names used in
the function declarator (including parameter types, return types and exception
specifications) may be private types or objects which would normally not be
accessible and the template may be a member template or member function which
would not normally be accessible. —endnote]

If there is non-overloaded member function Clang complies to the standard,
however if there is an overloaded member function it does not.
Code below:

template <typename PtrType, PtrType PtrValue, typename TagType>
struct private_access {
  friend PtrType get(TagType) { return PtrValue; }
};

class Foo
{
  void print0(int);
  void print();
  void print(int);
};

using A = void(int);
using B = A Foo::*;
struct Tag {};
template struct private_access<B, &Foo::print0, Tag>;// OK
template struct private_access<B, &Foo::print, Tag>; // ERROR, OK in GCC

int main() { return 0; }
Quuxplusone commented 6 years ago

https://wandbox.org/permlink/jTWB2BjzLOJUjytK

Quuxplusone commented 6 years ago

Attached test.cpp (439 bytes, text/plain): test file