public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15552] New: template inheritance does not recognize member variables
@ 2004-05-21 12:00 ziv at kashya dot com
  2004-05-21 12:29 ` [Bug c++/15552] " pcarlini at suse dot de
                   ` (14 more replies)
  0 siblings, 15 replies; 18+ messages in thread
From: ziv at kashya dot com @ 2004-05-21 12:00 UTC (permalink / raw)
  To: gcc-bugs

I have a simple c++ file (no header files) that compiles well with g++ 3.0.2 
and also, the original code (before simplification) that caused errors compiles 
on the 3.3 series. The file has a template class with a public member function 
and a derivative class. The derivative class does not recognize the member 
variable.
The gcc version is 3.4.0 compiled on Linux

The c++ file is (note that it does not use ANY headers)
template<class A>
  class Base {
  public:
    Base(const A& a_ber) {};
    virtual ~Base();
    A m_ber;
  };
  
template<class A>
    class Der : public Base<A> {
    public:
	Der(A a_ber): Base<A>(a_ber) {};
	void memFunc();
	void memFunc2();
    };

template<class A>
void Der<A>::memFunc()
{
  A temp = m_ber;
}

template<class A>
void Der<A>::memFunc2()
{
  A temp = Base<A>::m_ber;
}

int main(int argc,char**argv) {
  Der<int> x(3);
  x.memFunc();
  x.memFunc2();
}

=========================================================
The .ii file is:
# 1 "jojo.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "jojo.cc"

template<class A>
  class Base {
  public:
    Base(const A& a_ber) {};
    virtual ~Base();
    A m_ber;
  };

template<class A>
    class Der : public Base<A> {
    public:
 Der(A a_ber): Base<A>(a_ber) {};
 void memFunc();
 void memFunc2();
    };

template<class A>
void Der<A>::memFunc()
{
  A temp = m_ber;
}

template<class A>
void Der<A>::memFunc2()
{
  A temp = Base<A>::m_ber;
}

int main(int argc,char**argv) {
  Der<int> x(3);
  x.memFunc();
  x.memFunc2();
}
=========================================
And the compiler output is:

ziv-lnx:~/temp/logger> /tmp/cross/local/bin/g++ -v jojo.cc -save-temps
Reading specs from /tmp/cross/local/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ./configure --prefix=/tmp/cross/local --enable-languages=c,c++
Thread model: posix
gcc version 3.4.0
 /tmp/cross/local/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -E -quiet -v -
D_GNU_SOURCE jojo.cc -mtune=pentiumpro -o jojo.ii
ignoring nonexistent directory "/tmp/cross/local/lib/gcc/i686-pc-linux-
gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /tmp/cross/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
 /tmp/cross/local/lib/gcc/i686-pc-linux-
gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
 /tmp/cross/local/lib/gcc/i686-pc-linux-
gnu/3.4.0/../../../../include/c++/3.4.0/backward
 /usr/local/include
 /tmp/cross/local/include
 /tmp/cross/local/lib/gcc/i686-pc-linux-gnu/3.4.0/include
 /usr/include
End of search list.
 /tmp/cross/local/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -fpreprocessed 
jojo.ii -quiet -dumpbase jojo.cc -mtune=pentiumpro -auxbase jojo -version -o 
jojo.s
GNU C++ version 3.4.0 (i686-pc-linux-gnu)
        compiled by GNU C version 3.4.0.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64211
jojo.cc: In member function `void Der<A>::memFunc()':
jojo.cc:21: error: `m_ber' undeclared (first use this function)
jojo.cc:21: error: (Each undeclared identifier is reported only once for each 
function it appears in.)
Exit 1
====================================================
Note that if you comment out the line in memFunc, it compiles well. Also 
memFunc2 has no problems.

-- 
           Summary: template inheritance does not recognize member variables
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ziv at kashya dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 18+ messages in thread
[parent not found: <bug-15552-8583@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2006-01-13 15:50 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-21 12:00 [Bug c++/15552] New: template inheritance does not recognize member variables ziv at kashya dot com
2004-05-21 12:29 ` [Bug c++/15552] " pcarlini at suse dot de
2004-11-05 19:29 ` bangerth at dealii dot org
2004-11-05 19:29 ` bangerth at dealii dot org
2004-11-05 19:30 ` bangerth at dealii dot org
2004-11-05 19:30 ` bangerth at dealii dot org
2004-11-05 19:31 ` bangerth at dealii dot org
2004-11-05 19:31 ` bangerth at dealii dot org
2004-11-05 19:31 ` bangerth at dealii dot org
2004-11-05 19:32 ` bangerth at dealii dot org
2004-11-05 19:32 ` bangerth at dealii dot org
2004-11-05 19:32 ` bangerth at dealii dot org
2004-11-05 19:32 ` bangerth at dealii dot org
2004-11-05 19:33 ` bangerth at dealii dot org
2004-11-05 19:34 ` bangerth at dealii dot org
2005-05-18 12:37 ` tonne2005 at gehheimdienst dot de
     [not found] <bug-15552-8583@http.gcc.gnu.org/bugzilla/>
2006-01-13 15:50 ` pinskia at gcc dot gnu dot org
2006-01-13 15:50 ` 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).