🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by klotz Thu, 14 Sep 1989 01:13
bug with multiple-inheritance variable name conflict
#419
Author: klotz
Date: Thu, 14 Sep 1989 01:13
37 lines
1212 bytes
In g++ 1.36.0- the attached programs gives the following error:
    In function int main ():
    mu.cc:24: request for member `a' is ambiguous
when in fact, the reference to the member is properly qualified.
No output file is produced.

Casting the object to (top_left) or (top_right) or (top) works,
and produces an output file, but generates the apparently spurious error message
    In function int main ():
    mu.cc:24: warning: assignment to virtual aggregate type


#include <stdio.h>

struct top {
  int a = 0;
  virtual int report() { return a; };
};

struct top_left : public top {
  int a = 1;
};

struct top_right : public top {
  int a = 2;
};

struct bottom : public top_left, public top_right {
  int b;
};

main()
{
  bottom x;
  
  printf("%d\n", x.a);
}
Re: bug with multiple-inheritance variable name conflict
#422
Author: Tom Vijlbrief
Date: Thu, 14 Sep 1989 12:59
28 lines
1122 bytes
>main()
>{
>  bottom x;
>  
>  printf("%d\n", x.a);
>}

I think g++ is right in reporting that x.a is ambigious:

printf("%d\n", x.bottom::top_right::a);

works as expected.

printf("%d\n", x.top_right::a);

does however not work. I'm not so familair with MI so I'm not sure this is
a bug. 

Tom

===============================================================================
Tom Vijlbrief
TNO Institute for Perception
P.O. Box 23				Phone: +31 34 63 562 11
3769 ZG  Soesterberg			E-mail: tnosoes!tom@mcvax.cwi.nl
The Netherlands				    or:	uunet!mcvax!tnosoes!tom
===============================================================================
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads