This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13323] New: Template code does not compile in presence of typedef
- From: "david dot lee at teracruz dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 5 Dec 2003 21:01:51 -0000
- Subject: [Bug c++/13323] New: Template code does not compile in presence of typedef
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code compiles fine with gcc 3.2. However, with 3.3.2, I get an
error.
[dlee@d100-devel cpp]$ cat > bug.cpp <<EOF
typedef int INT_TYPEDEF;
template<class T>
class TypedIfc
{
public:
virtual ~TypedIfc() { }
virtual operator const T&() const = 0;
virtual const T& operator= (const T& t) = 0;
};
template<class Tnative>
class NullIfc : public TypedIfc<Tnative>
{
public:
const Tnative& operator= (const Tnative& t) { return t; }
operator const Tnative&() const { return *(Tnative *)0; }
};
#ifndef DONTBREAK // -DDONTBREAK to get a build that works.
typedef TypedIfc<INT_TYPEDEF> INT_TYPEDEFIfc;
#endif
NullIfc<int> i32;
EOF
[dlee@d100-devel cpp]$ i686-linux-g++ bug.cpp -o /dev/null -c -DDONTBREAK
[dlee@d100-devel cpp]$ i686-linux-g++ bug.cpp -o /dev/null -c
bug.cpp:24: error: cannot declare variable `i32' to be of type `NullIfc<int>'
bug.cpp:24: error: because the following virtual functions are abstract:
bug.cpp:8: error: TypedIfc<T>::operator const T&() const [with T =
INT_TYPEDEF]
Here's the info for my compiler:
[dlee@d100-devel cpp]$ i686-linux-g++ --verbose
Reading specs from /tools/i386/lib/gcc-lib/i686-linux/3.3.2/specs
Configured with: /src/gcc-3.3.2/configure --target=i686-linux --host=i686-
host_pc-linux-gnu --prefix=/tools/i386 --with-headers=/tools/i386/i686-
linux/include --disable-nls --enable-symvers=gnu --enable-threads=posix --
enable-__cxa_atexit --enable-languages=c,c++ --enable-clocale=gnu --with-local-
prefix=/home/dlee/vcs/Products/Breeze/Dev/Prj/LinuxRH8/tscale2/tools/i386/i686-
linux --disable-multilib
Thread model: posix
gcc version 3.3.2
--
Summary: Template code does not compile in presence of typedef
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: david dot lee at teracruz dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux
GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13323