1 /* { dg-do run } */
2 /* { dg-options "-fwhole-program" } */
3
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <math.h>
8 #include <string.h>
9
10 void mem_init (void);
11 int ARCHnodes, ARCHnodes1;
12 int ***vel;
13
14 /* The last dimension of VEL escapes because of
15 the assignment : vel[1][1] =...
16 Only the two external dimensions are flattened. */
17
18
19 /*--------------------------------------------------------------------------*/
20
21 int
main(int argc,char ** argv)22 main (int argc, char **argv)
23 {
24 int i, j, k;
25
26 ARCHnodes = 2;
27 ARCHnodes1 = 4;
28
29 /* Dynamic memory allocations and initializations */
30
31 mem_init ();
32
33 for (i = 0; i < ARCHnodes; i++)
34 {
35 for (j = 0; j < 3; j++)
36 {
37 for (k = 0; k < ARCHnodes1; k++)
38 printf ("[%d][%d][%d]=%d ", i, j, k, vel[i][j][k]);
39 printf ("\n");
40 }
41 printf ("\n");
42 }
43 for (i = 0; i < ARCHnodes; i++)
44 for (j = 0; j < 3; j++)
45 printf ("%x\n",vel[i][j]);
46 /*if (i!=1 || j!=1)*/
47 /*if (i==1 && j==1)
48 continue;
49 else
50 free (vel[i][j]);*/
51
52 for (i = 0; i < ARCHnodes; i++)
53 free (vel[i]);
54
55 free (vel);
56 return 0;
57 }
58
59 /*--------------------------------------------------------------------------*/
60 /* Dynamic memory allocations and initializations */
61
62 void
mem_init(void)63 mem_init (void)
64 {
65
66 int i, j, k,d;
67
68 d = 0;
69 vel = (int ***) malloc (ARCHnodes * sizeof (int **));
70
71 for (i = 0; i < ARCHnodes; i++)
72 {
73 vel[i] = (int **) malloc (3 * sizeof (int *));
74 if (vel[i] == (int **) NULL)
75 {
76 printf ("malloc failed for vel[%d]\n", i);
77 exit (0);
78 }
79 }
80 for (i = 0; i < ARCHnodes; i++)
81 {
82 for (j = 0; j < 3; j++)
83 {
84 vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
85 printf ("%x %d %d\n",vel[i][j], ARCHnodes1, sizeof (int));
86 }
87 }
88 for (i = 0; i < ARCHnodes; i++)
89 {
90 for (j = 0; j < 3; j++)
91 {
92 printf ("%x\n",vel[i][j]);
93 }
94 }
95
96 printf ("again:\n\n");
97 for (i = 0; i < ARCHnodes; i++)
98 {
99 for (j = 0; j < 3; j++)
100 {
101 printf ("%x\n",vel[i][j]);
102 /*for (k = 0; k < ARCHnodes1; k++)
103 {
104 vel[i][j][k] = d;
105 d++;
106 }*/
107 }
108 }
109 /*vel[1][1] = vel[0][1];*/
110 }
111
112 /*--------------------------------------------------------------------------*/
113