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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [20041219-1.c] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* PR18191 Struct member is not getting default-initialized.
2
   Origin: Grigory Zagorodnev  <grigory.zagorodnev@intel.com>  */
3
 
4
/* { dg-do run } */
5
 
6
extern int printf (__const char *__restrict __format, ...);
7
 
8
typedef struct S {
9
  const char* s;
10
  int         i;
11
} S;
12
 
13
void
14
foo (void)
15
{
16
  S dummy[2];
17
  unsigned i;
18
 
19
  /* Put some garbage on the stack.  */
20
  for (i = 0; i < sizeof(dummy); i++)
21
    ((char *)&dummy)[i] = -1;
22
}
23
 
24
int
25
bar (void)
26
{
27
  /* Allocate object on the stack.  */
28
  S obj[2] = { {"m0"}, {"m1"} };
29
 
30
  /* Assume fields those not explicitly initialized
31
     are default initialized to 0 [8.5.1/7 and 8.5/5].  */
32
  if (obj[0].i == 0)
33
    return 0;
34
  else
35
    {
36
      printf("Failed: obj[0].i == '%d', expecting '0'\n", obj[0].i);
37
      return 1;
38
    }
39
}
40
 
41
int
42
main (void)
43
{
44
  foo();
45
  return bar();
46
}
47
 

powered by: WebSVN 2.1.0

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