🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #419

bug with multiple-inheritance variable name conflict

#419
From: 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);
}
Technical Details
Message-ID: <8909140113.AA00938@fast.parc.xerox.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!tut.cis.ohio-state.edu!parc.xerox.com!klotz

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!ucsd!tut.cis.ohio-state.edu!parc.xerox.com!klotz
From: klotz@parc.xerox.com
Newsgroups: gnu.g++.bug
Subject: bug with multiple-inheritance variable name conflict
Message-ID: <8909140113.AA00938@fast.parc.xerox.com>
Date: 14 Sep 89 01:13:10 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 37