Bug 11329

Summary: Compiler cannot find user defined implicit typecast
Product: gcc Reporter: Jan Starzynski <jan>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P2    
Version: 3.3   
Target Milestone: 3.3.1   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

Description Jan Starzynski 2003-06-26 13:42:04 UTC
GCC 3.3 does not find the user defined typcast in the appended code. In gcc 2.95.3 
and Borland C++ 6 it does work. 
 
Compiling with "g++ bugsim2.cc" failes with: 
 
***** 
bugsim2.cc: In function `int main()': 
bugsim2.cc:27: error: could not convert `super' to `Base&' 
bugsim2.cc:21: error: in passing argument 1 of `void funcNonConst(Base&, 
   Derived&, const Base*)' 
***** 
 
gcc -v: 
bugsim2.cc: In function `int main()': 
bugsim2.cc:27: error: could not convert `super' to `Base&' 
bugsim2.cc:21: error: in passing argument 1 of `void funcNonConst(Base&, 
   Derived&, const Base*)' 
 
 
uname -a: 
Linux earth 2.4.20-4GB #1 Wed Jun 18 07:45:45 UTC 2003 i686 unknown unknown 
GNU/Linux 
 
Standard SuSE 8.2 on Pentium 4. 
 
****************************** 
class Base { 
}; 
 
class Derived: public Base { 
}; 
 
class Super { 
public: 
  Derived *derived; 
 
  Super(): derived(new Derived) {} 
  ~Super() { delete derived; } 
 
  Base *pointer() const { return derived; } 
 
  operator Base &() const { return *derived; } 
  operator Derived &() const { return *derived; } 
}; 
 
void funcNonConst(Base &base, Derived &derived, const Base *orig) 
{ 
} 
 
int main() 
{ 
  Super super; 
  funcNonConst(super, super, super.pointer()); 
}
Comment 1 Andrew Pinski 2003-06-26 14:17:58 UTC
Already fixed in 3.3.1 (20030616) and the mainline (20030626).
I think this is a dup but I cannot find the other bug report.
Comment 2 Andrew Pinski 2003-06-26 14:41:39 UTC
*** Bug 11328 has been marked as a duplicate of this bug. ***