[Bug c++/31623] New: Template Inheritance Regression from 3.3 (accessing protected member from sublcass)

myrd at projectmagma dot net gcc-bugzilla@gcc.gnu.org
Wed Apr 18 15:21:00 GMT 2007


The following code (simplified for clarity), does not compile on GCC versions
past 4.0, but compiles fine with gcc-3.3 and other non-GCC compilers (MSVC++,
etc):

#include <stdio.h>

template<int elem_size>
class VectorBase
{

protected:

        char * memory;

public:

        VectorBase()
        {
                memory = NULL;
        }
};

template<typename T>
struct Vector : public VectorBase<sizeof(T)>
{
        T * ptr()
        {
                return (T*)memory;
        }
};


int main() {
        return 0;
}


-- 
           Summary: Template Inheritance Regression from 3.3 (accessing
                    protected member from sublcass)
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: myrd at projectmagma dot net


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



More information about the Gcc-bugs mailing list