[LLVMbugs] [Bug 18079] New: default template argument privacy

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Nov 27 08:08:51 PST 2013


http://llvm.org/bugs/show_bug.cgi?id=18079

            Bug ID: 18079
           Summary: default template argument privacy
           Product: clang
           Version: 3.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kusmabite at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code does not compile with Clang:

---8<---
template <class Bar, int Bar::*PtrToInt = &Bar::myInt>
class Foo {};

class Bar {
private:
    int myInt;
public:
    void FooBar()
    {
        // does not compile:
        Foo<Bar> test;
        // does compile:
        // Foo<Bar, &Bar::myInt> test;
    }
};
---8<---

Clang errors as follows:

---8<---
clang-issue.cpp:1:49: error: 'myInt' is a private member of 'Bar'
template <class Bar, int Bar::*PtrToInt = &Bar::myInt>
                                                ^
clang-issue.cpp:11:3: note: in instantiation of default argument for 'Foo<Bar>'
required here
                Foo<Bar> test;
                ^~~~~~~~
clang-issue.cpp:6:6: note: declared private here
        int myInt;
            ^
1 error generated.
---8<---

This differs from how both GCC and MSVC handles privacy of default template
arguments: it seems Clang considers privacy in the context of the template
definition in this case, whereas GCC and MSVC considers it at the call-site.

Which is correct? Since Clang differs from the two major implementations, my
guess would be that Clang was in the wrong, but I don't really know how to read
the C++ spec to be sure...

-- 
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/20131127/338cb6ba/attachment.html>


More information about the llvm-bugs mailing list