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
This is clearly a bug, and a regression on 3.3/mainline w.r.t. 3.2.x. Here's an extract: ------------------------- template <class T> struct B { virtual operator T() const = 0; }; template <class T> struct D : B<T> { virtual operator T() const; }; typedef int i; typedef B<i> Bi; D<int> i32; --------------------------- g/x> /home/bangerth/bin/gcc-3.2.3/bin/c++ -c x.cc g/x> /home/bangerth/bin/gcc-3.3.3-pre/bin/c++ -c x.cc x.cc:13: error: cannot declare variable `i32' to be of type `D<int>' x.cc:13: error: because the following virtual functions are abstract: x.cc:2: error: B<T>::operator T() const [with T = i] W.
From Phil's regression hunter: Search converges between 2003-06-17-trunk (#316) and 2003-06 -18-trunk (#317). : Search converges between 2003-06-14-3.3 (#145) and 2003-06-22-3.3 (#146). Related to bug 11928 and PR 11713 (the ones caused also in the same time period, both of them the same patch). So it is most likely the same patch: 2003-06-17 Mark Mitchell <mark@codesourcery.com> PR c++/11105 * cp-tree.h (DECL_CONV_FN_TYPE): New method. * decl.c (lookup_name_real): Backport conversion operator code from mainline. * mangle.c (struct globals): Remove internal_mangling_p. (write_unqualified_name): Use DECL_CONV_FN_TYPE. (write_template_parm): Don't write out the level number. (conv_type_names): New variable. (hash_type): New function. (compare_type): Likewise. (mangle_conv_op_name_for_type): Don't try to mangle conversion operator names. * search.c (lookup_conversion_operator): New function. (lookup_fnfields_1): Use it. Mark could you look at this one?
Subject: Bug 13323 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-12-06 22:11:46 Modified files: gcc/cp : ChangeLog class.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/inherit: operator2.C Log message: PR c++/13323 * class.c (same_signature_p): Handle conversion operators correctly. (check_for_override): Likewise. PR c++/13323 * g++.dg/inherit/operator2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3785&r2=1.3786 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.583&r2=1.584 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3234&r2=1.3235 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/operator2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 13323 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: mmitchel@gcc.gnu.org 2003-12-06 22:19:31 Modified files: gcc/cp : ChangeLog class.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/inherit: operator2.C Log message: PR c++/13323 * class.c (same_signature_p): Handle conversion operators correctly. (check_for_override): Likewise. PR c++/13323 * g++.dg/inherit/operator2.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.221&r2=1.3076.2.222 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.499.2.24&r2=1.499.2.25 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.324&r2=1.2261.2.325 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/operator2.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.3.3 and GCC 3.4.
Thanks for the prompt response! This fix gets me going again :-)