llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.67k stars 11.86k forks source link

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

Open martong opened 6 years ago

martong commented 6 years ago
Bugzilla Link 35647
Version unspecified
OS All
CC @DougGregor,@martong

Extended Description

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; }

martong commented 6 years ago

test file

martong commented 6 years ago

https://wandbox.org/permlink/jTWB2BjzLOJUjytK

llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-frontend