public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13323] New: Template code does not compile in presence of typedef
@ 2003-12-05 21:01 david dot lee at teracruz dot com
  2003-12-05 21:12 ` [Bug c++/13323] [3.3/3.4 regression] " bangerth at dealii dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: david dot lee at teracruz dot com @ 2003-12-05 21:01 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-12-08 22:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-05 21:01 [Bug c++/13323] New: Template code does not compile in presence of typedef david dot lee at teracruz dot com
2003-12-05 21:12 ` [Bug c++/13323] [3.3/3.4 regression] " bangerth at dealii dot org
2003-12-06  2:46 ` pinskia at gcc dot gnu dot org
2003-12-06 22:11 ` cvs-commit at gcc dot gnu dot org
2003-12-06 22:19 ` cvs-commit at gcc dot gnu dot org
2003-12-06 22:20 ` mmitchel at gcc dot gnu dot org
2003-12-08 22:17 ` david dot lee at teracruz 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).