When explicitly invoking a template class destructor the compiler outputs a
compile-time error message, "expected class-name before '(' token."
NOTE: Same code compiles on 'gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)'
Found problem while compiling ACE-TAO 5.4 code and broke it down further for
simplicity.
=== g++ -v output ====
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux
Thread model: posix
gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)
=== Command that triggers error message ===
g++ -c a.cpp
==== Compile-time error message ====
g++ -c a.cpp
a.cpp: In member function `void B<T>::delete_nodes()':
a.cpp:42: error: expected class-name before '(' token
==== a.ii ====
# 1 "a.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "a.cpp"
template<class T> class A
{
public:
A (void);
~A (void);
void testfunc (void);
};
template <class T> A<T>::A (void) {}
template <class T> A<T>::~A (void) {}
template <class T> void A<T>::testfunc (void) {}
template <class T> class B
{
public:
B (void);
~B (void);
protected:
void delete_nodes (void);
A<T> *head_;
};
template <class T> B<T>::B (void) {}
template <class T> B<T>::~B (void) {}
template <class T> void B<T>::delete_nodes (void)
{
A<T> *temp = this->head_;
if (temp)
(temp)->~A();
if (temp)
(temp)->testfunc();
}
--
Summary: Explicitly invoking destructor of template class
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: eric dot tenorio at gmail dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: 3.4.4
GCC host triplet: 3.4.4
GCC target triplet: 3.4.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23287