Bug 11329 - Compiler cannot find user defined implicit typecast
Summary: Compiler cannot find user defined implicit typecast
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3
: P2 normal
Target Milestone: 3.3.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 11328 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-06-26 13:42 UTC by Jan Starzynski
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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. ***