public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/15894] New: Template inheritance problem with base class member
@ 2004-06-09 12:38 marzullo at la-defense dot oilfield dot slb dot com
2004-06-09 12:56 ` [Bug c++/15894] " marzullo at la-defense dot oilfield dot slb dot com
0 siblings, 1 reply; 2+ messages in thread
From: marzullo at la-defense dot oilfield dot slb dot com @ 2004-06-09 12:38 UTC (permalink / raw)
To: gcc-bugs
When creating template inheritance (see program), we can not access base
template member while in the derivated template.
#include <iostream>
template <typename _type>
class MyClass
{
public:
_type m_value;
};
template <typename _type>
class AnotherClass : public MyClass<_type>
{
public:
void print( void ) const
{
std::cerr << "m_value = " << m_value << '\n';
}
};
int
main( void )
{
AnotherClass<bool> a;
std::cerr << "sizeof(wchar_t) " << sizeof(wchar_t) << '\n';
a.print();
return 0;
}
Reading specs from /opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/specs
Configured with: ../../SOURCES/gcc-3.4.0/configure --prefix=/opt/gcc/3.4.0
--enable-threads=posix --enable-languages=c++
Thread model: posix
gcc version 3.4.0
/opt/gcc/3.4.0/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -E -quiet -v
-D_GNU_SOURCE template.cpp -mtune=pentiumpro -o template.ii
ignoring nonexistent directory
"/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0
/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/i686-pc-linux-gnu
/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/backward
/usr/local/include
/opt/gcc/3.4.0/include
/opt/gcc/3.4.0/lib/gcc/i686-pc-linux-gnu/3.4.0/include
/usr/include
End of search list.
/opt/gcc/3.4.0/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -fpreprocessed
template.ii -quiet -dumpbase template.cpp -mtune=pentiumpro -auxbase template
-version -o template.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=64183
template.cpp: In member function `void AnotherClass<_type>::print() const':
template.cpp:18: error: `m_value' undeclared (first use this function)
template.cpp:18: error: (Each undeclared identifier is reported only once for
each function it appears in.)
Regards
Laurent Marzullo
--
Summary: Template inheritance problem with base class member
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: marzullo at la-defense dot oilfield dot slb dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-redhat-linux
GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15894
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/15894] Template inheritance problem with base class member
2004-06-09 12:38 [Bug c++/15894] New: Template inheritance problem with base class member marzullo at la-defense dot oilfield dot slb dot com
@ 2004-06-09 12:56 ` marzullo at la-defense dot oilfield dot slb dot com
0 siblings, 0 replies; 2+ messages in thread
From: marzullo at la-defense dot oilfield dot slb dot com @ 2004-06-09 12:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From marzullo at la-defense dot oilfield dot slb dot com 2004-06-09 12:56 -------
Solution has been given by Florian Weimer:
You don't have to specify the base class, using "this->" is quiteenough. GCC
3.4 requires C++ programs to conform more closely to thestandard, and the issue
you spotted is a consequence.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15894
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-06-09 12:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-09 12:38 [Bug c++/15894] New: Template inheritance problem with base class member marzullo at la-defense dot oilfield dot slb dot com
2004-06-09 12:56 ` [Bug c++/15894] " marzullo at la-defense dot oilfield dot slb dot com
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).