public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11876] New: Cannot access protected member from templated copy constructor
@ 2003-08-10 15:39 ktulu at free dot fr
  2003-08-10 16:13 ` [Bug c++/11876] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ktulu at free dot fr @ 2003-08-10 15:39 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Cannot access protected member from templated copy
                    constructor
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ktulu at free dot fr
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: ppc-darwin

Results from the command line:

bash-2.05a$ gcc -v -save-temps Test-2.cpp
Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs
Thread model: posix
gcc version 3.3 20030304 (Apple Computer, Inc. build 1435)
 /usr/libexec/gcc/darwin/ppc/3.3/cc1plus -E -D__GNUG__=3 -quiet -v -D__GNUC__=3 -
D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 -D__APPLE_CC__=1435 -D__DYNAMIC__ 
Test-2.cpp -fPIC -D__private_extern__=extern Test-2.ii
ignoring nonexistent directory "/usr/ppc-darwin/include"
ignoring nonexistent directory "/Local/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/gcc/darwin/3.3/c++
 /usr/include/gcc/darwin/3.3/c++/ppc-darwin
 /usr/include/gcc/darwin/3.3/c++/backward
 /usr/local/include
 /usr/include/gcc/darwin/3.3
 /usr/include
End of search list.
Framework search starts here:
 /System/Library/Frameworks
 /Library/Frameworks
End of framework search list.
 /usr/libexec/gcc/darwin/ppc/3.3/cc1plus -fpreprocessed Test-2.ii -fPIC -quiet -dumpbase 
Test-2.cpp -auxbase Test-2 -version -D__private_extern__=extern -o Test-2.s
GNU C++ version 3.3 20030304 (Apple Computer, Inc. build 1435) (ppc-darwin)
        compiled by GNU C version 3.3 20030304 (Apple Computer, Inc. build 1435).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=131072
Test-2.cpp: In constructor `A<T>::A(const A<U>&) [with U = int, T = float]':
Test-2.cpp:26:   instantiated from here
Test-2.cpp:7: error: `int A<int>::_data' is protected
Test-2.cpp:10: error: within this context

The intermediate file:

# 1 "Test-2.cpp"
#pragma GCC set_debug_pwd "/Users/ktulu/Projects/Ktk/MacOs 10/Pb/Test"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "Test-2.cpp"
template <typename T>
class A
{
        friend class A<int>;
        friend class A<float>;
protected:
        T _data;
        inline A() : _data(0) {}
        template <typename U>
        inline A(const A<U>& r) : _data(r._data) {}


};

class B : public A<int>
{
public:
        inline B() {}
        inline B(const B& r) : A<int>(r) {}
};

class C : public A<float>
{
public:
        inline C() {}
        inline C(const B& r) : A<float>(r) {}
};


int main(int, char*[])
{
        B b1, b2(b1);
        C c(b1);
        return 0;
}

The original code snippet:

template <typename T>
class A
{
	friend class A<int>;
	friend class A<float>;
protected:
	T _data;
	inline A() : _data(0) {}
	template <typename U>
	inline A(const A<U>& r) : _data(r._data) {}
};

class B : public A<int>
{
public:
	inline B() {}
	inline B(const B& r) : A<int>(r) {}
};

class C : public A<float>
{
public:
	inline C() {}
	inline C(const B& r) : A<float>(r) {}
};

int main(int, char*[])
{
	B b1, b2(b1);
	C c(b1);
	return 0;
}


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-08-23 14:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-10 15:39 [Bug c++/11876] New: Cannot access protected member from templated copy constructor ktulu at free dot fr
2003-08-10 16:13 ` [Bug c++/11876] " pinskia at gcc dot gnu dot org
2003-08-11 12:47 ` lerdsuwa at gcc dot gnu dot org
2003-08-16 12:12 ` lerdsuwa at gcc dot gnu dot org
2003-08-22  2:11 ` pinskia at gcc dot gnu dot org
2003-08-22 13:49 ` lerdsuwa at gcc dot gnu dot org
2003-08-23 14:17 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).