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()); }
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.
*** Bug 11328 has been marked as a duplicate of this bug. ***