Bug 11928 - [3.3.1/3.4 regression] c++ typedef handling
Summary: [3.3.1/3.4 regression] c++ typedef handling
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.2
: P1 critical
Target Milestone: 3.3.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-15 13:49 UTC by Debian GCC Maintainers
Modified: 2004-01-17 04:22 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-15 14:10:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 Andrew 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 Andrew 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
        * 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 5 CVS Commits 2003-08-29 23:51:23 UTC
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

Comment 6 CVS Commits 2003-08-29 23:56:23 UTC
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

Comment 7 Mark Mitchell 2003-08-29 23:57:23 UTC
Fixed in GCC 3.3, GCC 3.4.