This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bogus error message? (covariant return types)
- To: Joe Buck <jbuck at synopsys dot com>
- Subject: Re: Bogus error message? (covariant return types)
- From: Omar Loggiodice <ologgio at vrainn dot com>
- Date: Thu, 18 Dec 1997 22:41:41 -0500 (EST)
- cc: egcs at cygnus dot com
On Thu, 18 Dec 1997, Joe Buck wrote:
>
> > Now to the potential bug. If I compile the following code with egcs-1.0
> > (plus H.J. patches for RedHat 5.0) I get an error message saying:
> >
> > covariant-bug1.cc:26: sorry, not implemented:
> > adjusting pointers for covariant returns
>
> Sigh. Any message beginning "sorry, not implemented" means that while you
> have written correct C++, the compiler cannot handle the code. The
> compiler is even apologizing for you. Given how polite the compiler is
> being to you, it seems rather impolite to complain about a "bogus error
> message".
>
I --obviously-- understand this, that is why I said "potential" bug, and
it is also the reason why I put a question mark after "bogus error
message". I was not trying to be impolite by any measure, I actually was
trying to get more information (which you did supply afterwards, thanks
for that). I wasn't sure this was a bogus error message, again, that is
why I used a question mark in my subject.
Since I am completely aware of the fact that egcs and previous versions of
gcc support covariant return types (in the single inhertance cases where
I've used it before) I was wondering wether the "sorry, not implemented"
error was some historic code from the times when covariant return types
where not properly supported. I had no idea of the fact that the
implementation for covariant return types is a partial implementation,
that is what led me to believe that *maybe* (hence the question mark and
the word 'potential') this was a bogus error message. Sorry if that meant
impoliteness to you, it was not my intention at all.
> > However, if I change the order of the base classes the code compiles and
> > runs perfectly.
>
> That's because if you change the order of the baseclasses, the offset
> becomes zero and the compiler doesn't need to adjust the pointer returned
> by C::who. That is, with
>
> class C: public A, public B
>
> Then we can convert a C* to an A* with no code, but converting a C* to
> a B* requires adding an offset to the address of the pointer. This is
> what is not implemnted.
>
Thanks, this is the information I was looking for. Appreciate it.
[...]
> > Here is the workaround:
>
> Sorry, that kind of workaround won't help people who cannot change their
> inheritance structure for other reasons. But it will work for some
> people.
Agreed, for some projects it might not work at all. It does help many
others though.
____________________________________________________________________
/ __ __ __ - __ __ / - _ __ ologgio@vrainn.com
Omar R. /__ /_/ /_/ /_/ / /_/ /_/ / /_ /-_ CIS: 74040,1543
__/ __/
___C++/7_yrs____Virtual Reality/4_yrs____Vorl_____Linux(free)_______
Linux: A Unix OS for _you_ ...ftp://sunsite.unc.edu/pub/Linux