[llvm-bugs] [Bug 35647] New: C++ standard violation: [templates][explicit instantiation][access checking][pointer to overloaded member function]

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 12 13:18:00 PST 2017


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

            Bug ID: 35647
           Summary: C++ standard violation: [templates][explicit
                    instantiation][access checking][pointer to overloaded
                    member function]
           Product: clang
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: martongabesz at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

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

-- 
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/20171212/01920d5d/attachment.html>


More information about the llvm-bugs mailing list