From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17926 invoked by alias); 22 Jun 2005 17:58:30 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 17915 invoked by uid 22791); 22 Jun 2005 17:58:27 -0000 Received: from [209.10.210.110] (HELO internet.interraeda.com) (209.10.210.110) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 22 Jun 2005 17:58:27 +0000 Received: from InterraSystems.com (redhat [192.9.199.18]) by internet.interraeda.com (8.11.6/8.11.6) with ESMTP id j5MHwOg17478 for ; Wed, 22 Jun 2005 10:58:24 -0700 (PDT) Message-ID: <42B9A65A.3030403@InterraSystems.com> Date: Wed, 22 Jun 2005 17:58:00 -0000 From: Shelly Adhikari User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 MIME-Version: 1.0 To: gcc@gcc.gnu.org Subject: gcc template error? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-06/txt/msg00975.txt.bz2 Hello Guys, Thw following program is giving an error. Is the program incorrect (If possible, please cite relevant sections from the C++ standard)? Should I file a bug? % /usr/local/gcc-4.0.0/bin/g++ template.cxx template.cxx: In function 'T* func(T*) [with X = B, Y = A]': template.cxx:36: instantiated from here template.cxx:21: error: 'A* T::m_' is private template.cxx:30: error: within this context // Line 1 class A { public: A() { }; ~A() { }; }; class B { public: B(); B(const A& a) { }; ~B(); }; template class T; template T* func(T* p); template class T { X* m_; public: T(X* x) : m_(x) { }; ~T() { }; friend T* func(T* p); }; template T* func(T* p) { return (new T(new X(*p->m_))); } int main() { A* a = new A(); T* p = new T(a); T* q = func(p); return 0; } Best Regards, Shelly