OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.old-deja/] [g++.mike/] [p2846a.C] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 305 jeremybenn
// { dg-do run  }
2
// Shows that problem of initializing one object's vtable pointer from
3
// another object's vtable pointer when doing a default copy of it
4
// and the vtable pointer involved is the main one.
5
 
6
// Correct answer is B::print.
7
// g++ prints D::print, which is wrong.  Cfront gets is right.
8
 
9
// prms-id: 2846
10
 
11
extern "C" int printf(const char *, ...);
12
extern "C" void exit(int);
13
 
14
class B {
15
public:
16
  virtual void print(void) const { printf("B::print\n"); }
17
};
18
 
19
class D : public B {
20
public:
21
  void print(void) const { printf("D::print\n"); exit(1); }
22
  B compute(void) const;
23
};
24
 
25
B D::compute(void) const
26
{
27
  B sub(*(B*)this);
28
  return sub;
29
}
30
 
31
int main () {
32
  D titi;
33
  titi.compute().print();
34
  return 0;
35
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.