public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* covariant returns
@ 2001-11-20 11:45 Stefan Seefeld
  2001-11-20 16:13 ` Nathan Sidwell
  2001-11-27 21:47 ` Stefan Seefeld
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Seefeld @ 2001-11-20 11:45 UTC (permalink / raw)
  To: gcc

hi there,

I'm trying to compile a file that contains class trees
that use covariant return types. At some point I get
the error message:

sorry, not implemented: adjusting pointers for covariant returns

(gcc version 2.95.3 on linux x86)

However, I'm unable to reproduce that problem in
a simplified example. Could anybody please explain
under what conditions covariant return types are/are not
supported ?

Thanks a lot,
		Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: covariant returns
  2001-11-20 11:45 covariant returns Stefan Seefeld
@ 2001-11-20 16:13 ` Nathan Sidwell
  2001-11-28  1:00   ` Nathan Sidwell
  2001-11-27 21:47 ` Stefan Seefeld
  1 sibling, 1 reply; 7+ messages in thread
From: Nathan Sidwell @ 2001-11-20 16:13 UTC (permalink / raw)
  To: Stefan Seefeld; +Cc: gcc

Stefan Seefeld wrote:

> sorry, not implemented: adjusting pointers for covariant returns

> However, I'm unable to reproduce that problem in
> a simplified example. Could anybody please explain
> under what conditions covariant return types are/are not
> supported ?
g++ currently (both 2.95 & 3.0 series) supports only trivial covariance.

This means that the class named in the return type of the overridden
virtual function must be at offset zero in the derived class named in
the return type of the overriding virtual function.  This is true for
non-virtual single inheritance[1], and for the first non-virtual base
in multiple inheritance[2]

nathan

[1] This is a lie in the new ABI. An exception is that if the base is
non-polymorphic and the derived class is polymorphic, the base will not
be at offset zero.

[2] This too is a lie in the new ABI.  [1] applies. Also if the base
is non-polymorphic & without virtual bases, but the derived class is
non-polymorphic but contains virtual bases, then the first non-virtual base
will not be at offset zero.

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* covariant returns
  2001-11-20 11:45 covariant returns Stefan Seefeld
  2001-11-20 16:13 ` Nathan Sidwell
@ 2001-11-27 21:47 ` Stefan Seefeld
  1 sibling, 0 replies; 7+ messages in thread
From: Stefan Seefeld @ 2001-11-27 21:47 UTC (permalink / raw)
  To: gcc

hi there,

I'm trying to compile a file that contains class trees
that use covariant return types. At some point I get
the error message:

sorry, not implemented: adjusting pointers for covariant returns

(gcc version 2.95.3 on linux x86)

However, I'm unable to reproduce that problem in
a simplified example. Could anybody please explain
under what conditions covariant return types are/are not
supported ?

Thanks a lot,
		Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: covariant returns
  2001-11-20 16:13 ` Nathan Sidwell
@ 2001-11-28  1:00   ` Nathan Sidwell
  0 siblings, 0 replies; 7+ messages in thread
From: Nathan Sidwell @ 2001-11-28  1:00 UTC (permalink / raw)
  To: Stefan Seefeld; +Cc: gcc

Stefan Seefeld wrote:

> sorry, not implemented: adjusting pointers for covariant returns

> However, I'm unable to reproduce that problem in
> a simplified example. Could anybody please explain
> under what conditions covariant return types are/are not
> supported ?
g++ currently (both 2.95 & 3.0 series) supports only trivial covariance.

This means that the class named in the return type of the overridden
virtual function must be at offset zero in the derived class named in
the return type of the overriding virtual function.  This is true for
non-virtual single inheritance[1], and for the first non-virtual base
in multiple inheritance[2]

nathan

[1] This is a lie in the new ABI. An exception is that if the base is
non-polymorphic and the derived class is polymorphic, the base will not
be at offset zero.

[2] This too is a lie in the new ABI.  [1] applies. Also if the base
is non-polymorphic & without virtual bases, but the derived class is
non-polymorphic but contains virtual bases, then the first non-virtual base
will not be at offset zero.

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Covariant Returns
@ 2000-02-15  9:02 Will
  0 siblings, 0 replies; 7+ messages in thread
From: Will @ 2000-02-15  9:02 UTC (permalink / raw)
  To: gcc

I've experienced similar problems with covariant returns ...

The situation arises when overloading an inherited virtual function that

returns a class possessing a virtual base class, where the
aforementioned overloaded virtual function returns a derived form of the

return class ...



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Covariant Returns
  2000-02-15  0:07 Benjamin Scherrey
@ 2000-02-15  0:53 ` Martin v. Loewis
  0 siblings, 0 replies; 7+ messages in thread
From: Martin v. Loewis @ 2000-02-15  0:53 UTC (permalink / raw)
  To: scherrey; +Cc: gcc

> Is work progressing on this issue and is there any expectation that
> this feature will be available any time soon?

I'm not aware of any effort in that direction. Most likely, this won't
be available before the new ABI, which has a standard way of dealing
with feature.

> PS: If anyone wants to look at about 46Kbytes of source code to see
> this bug I'd be happy to send it. Its lots of templates and
> inheritance but the bug is easily reproduced within this code, just
> hard to re-implement in a smaller scenario.. I know I know... :-(

There is no problem with sending large examples if they are self
contained and give clear status information (pass/fail).

Regards,
Martin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Covariant Returns
@ 2000-02-15  0:07 Benjamin Scherrey
  2000-02-15  0:53 ` Martin v. Loewis
  0 siblings, 1 reply; 7+ messages in thread
From: Benjamin Scherrey @ 2000-02-15  0:07 UTC (permalink / raw)
  To: gcc

	I've got a rather complex multiple-inheritance situation (no, it
really can't be eliminated) where covariant returns would greatly
simply my code by allowing me to specify an additional parent as
virtual. Looking back at the messages in this forum on the subject, it
seems like there's quite a bit of work before this is fully
implemented. Is work progressing on this issue and is there any
expectation that this feature will be available any time soon? 
	
	Presently we're using the gcc-2.95.2 release under Intel/Linux &
Solaris. As it is, my current work-around sometimes results in a
bizarre and unneeded constructor being executed and a pure-virtual
method being called afterwards. This results simply from accessing a
data item in the leaf-class instance from a function defined in that
leaf. It makes no sense (appears to be a true compiler bug) and I'm
trying to construct a smaller test case reproduction but my true
solution would be to abandon the work-around if covariant returns were
implemented. 

	thanx & later,

		Ben Scherrey

PS: If anyone wants to look at about 46Kbytes of source code to see
this bug I'd be happy to send it. Its lots of templates and
inheritance but the bug is easily reproduced within this code, just
hard to re-implement in a smaller scenario.. I know I know... :-(

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-11-28  9:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-20 11:45 covariant returns Stefan Seefeld
2001-11-20 16:13 ` Nathan Sidwell
2001-11-28  1:00   ` Nathan Sidwell
2001-11-27 21:47 ` Stefan Seefeld
  -- strict thread matches above, loose matches on Subject: below --
2000-02-15  9:02 Covariant Returns Will
2000-02-15  0:07 Benjamin Scherrey
2000-02-15  0:53 ` Martin v. Loewis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).