OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [expr/] [assign1.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do run }
2
 
3
// Contributed by Nathan Sidwell 15 Dec 2003 
4
// Origin: Tasso Karkanis 
5
// PR c++/13387. Clobbered tail padding of base
6
 
7
inline void *operator new (__SIZE_TYPE__, void *ptr)
8
{
9
  return ptr;
10
}
11
 
12
struct Base {
13
    Base() : i(0), c(0) {}
14
    int i;
15
    char c;
16
};
17
 
18
struct Sub : Base {
19
    Sub () : d(0) {}
20
    char d;
21
};
22
 
23
int main() {
24
  Sub sub;
25
  char base_alias[sizeof (Base)];
26
  Base *base;
27
 
28
  for (unsigned ix = sizeof base_alias; ix--;)
29
    base_alias[ix] = 0x55;
30
  base = new (&base_alias) Base ();
31
 
32
  static_cast  (sub) = *base;
33
  return sub.d;
34
}

powered by: WebSVN 2.1.0

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