[forwarded from http://bugs.debian.org/205402] g++-3.3 fails to compile the code in test.cc with the following message: test.cc: In function `int main(int, char**)': test.cc:22: error: conversion from `BClass' to `B*' is ambiguous test.cc:16: error: candidates are: BClass::operator B*() test.cc:9: error: AClass::operator A*() Although it correctly compiles the equivalent code in test2.cc --- begin test.cc --- typedef struct _A A; typedef struct _A B; void some_function(B *b); class AClass { public: operator A*() { return 0;} }; class BClass :public AClass { public: operator B*() { return 0;} }; int main(int argc, char **argv) { BClass b; some_function(b); } --- end test.cc --- --- begin test2.cc --- void some_function(struct _A *b); class AClass { public: operator struct _A*() { return 0;} }; class BClass :public AClass { public: operator struct _A*() { return 0;} }; int main(int argc, char **argv) { BClass b; some_function(b); } --- end test2.cc ---
I don't have 3.3.1 lying around on this machine, but I can confirm that a) this problem doesn't happen in 3.3.0 b) doesn't happen with a mainline snapshot from mainline c) does happen with this night's mainline You specified as the version you have "3.3.3", which I doubt since we only just released 3.3.1. Can you double-check? I wonder whether this PR is related to PR 11919 which also has problems with typedefs not being equivalents for types. W.
The problem is that version 3.3.3 was added instead of 3.3.2. I have fixed that.
This is a regression from 3.3. From Phil's regression hunter : Search converges between 2003-06-14-3.3 (#145) and 2003-06-22-3.3 (#146). : Search converges between 2003-06-17-trunk (#316) and 2003-06-18-trunk (#317).
The regression in PR 11928 was introduced or exposed with this patch: --- gcc/gcc/cp/ChangeLog --- 2003-06-17 Mark Mitchell <mark@codesourcery.com> PR c++/11105 * cp-tree.h (DECL_CONV_FN_TYPE): New method. * 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. The regression hunt took place on i686-pc-linux-gnu using the submitter's test case (test.cc) with CVS mainline. The 3.3 version of the patch introduced or exposed the same problem on the branch.
Subject: Bug 11928 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2003-08-29 23:51:17 Modified files: gcc/cp : ChangeLog search.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/inherit: conv1.C Log message: PR c++/11928 * search.c (add_conversions): Avoid adding two conversion operators for the same type. PR c++/11928 * g++.dg/inherit/conv1.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3631&r2=1.3632 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&r1=1.279&r2=1.280 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3013&r2=1.3014 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/conv1.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 11928 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: mmitchel@gcc.gnu.org 2003-08-29 23:56:19 Modified files: gcc/cp : ChangeLog search.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/inherit: conv1.C Log message: PR c++/11928 * search.c (add_conversions): Avoid adding two conversion operators for the same type. PR c++/11928 * g++.dg/inherit/conv1.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.194&r2=1.3076.2.195 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.243.2.16&r2=1.243.2.17 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.262&r2=1.2261.2.263 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/inherit/conv1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1
Fixed in GCC 3.3, GCC 3.4.