11928 – [3.3.1/3.4 regression] c++ typedef handling (original) (raw)
Description Debian GCC Maintainers 2003-08-15 13:49:29 UTC
[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 ---
Comment 1 Wolfgang Bangerth 2003-08-15 14:10:27 UTC
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.
Comment 2 Drea Pinski 2003-08-15 14:13:32 UTC
The problem is that version 3.3.3 was added instead of 3.3.2. I have fixed that.
Comment 3 Drea Pinski 2003-08-22 00:26:22 UTC
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).
Comment 4 janis187 2003-08-29 01:35:11 UTC
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](show%5Fbug.cgi?id=11105 "RESOLVED FIXED - [3.3/3.4 regression of sorts] ICE in mangle_conv_op_name_for_type")
* 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.
Comment 7 Mark Mitchell 2003-08-29 23:57:23 UTC
Fixed in GCC 3.3, GCC 3.4.