failing versions: 4.0.1 (FSF), 4.0.0 (Apple, build 5026), 3.4.0 (FSF) -- 
platform-independent

working vesions: 3.3 (Apple, build 4061), 3.3 (FSF) -- platform-independent

to reproduce: g++ visibug.cc

'failing' versions reject with the same diagnostic:
visibug.cc: In member function 'void A<T>::foo() const [with T = int]':
visibug.cc:20:   instantiated from here
visibug.cc:15: error: 'A<int>' is an inaccessible base of 'B'

somewhat reduced test case "visibug.cc":
template <class T>
class A {
protected:
void foo(void) const;
};

class B : private A<int> {
public:
void bar(void) const;
};

template <class T>
void
A<T>::foo(void) const {
        static_cast<const B&>(*this);
}

void
B::bar(void) const {
        A<int>::foo();
}
// end of "visibug.cc"

Remarks:
Wasn't able to find any remarks about this particular case in bugzilla (terms: 
cast, visib, accessibl), nor 
did I find a comment about C++ language changes in the 3.4 release docs.  I 
suspect either this is a 
reject-valid bug, OR there's something in the standard that says this is 
invalid, and that 3.4+ are just 
conforming to it.  (Or I'm extremely tired and my eyes just glossed over it.)  
If invalid, kindly reference 
the relevant section?

-- 
           Summary: inaccessible base in static_cast from template base type
                    to non-template derived type
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fang at csl dot cornell dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23849

Reply via email to