Section 3.8
Replication example is not correct
In 3.8, REPLACE
Replicate operators
can be used to set the values for the exact number of members. The inner pair
of braces
in a replication is
removed.
struct {int X,Y,Z;} XYZ = '{3{1}};
typedef struct {int a,b[4];} ab_t;
int a,b,c;
ab_t v1[1:0]
[2:0];
v1 = '{2{'{3{a,'{2{b,c}}}}}};
/* expands to '{'{3{'{a,{2{b,c}}}}},
'{3{{a,'{2{b,c}}}}}} */
/* expands to '{'{'{a,'{2{b,c}}},'{a,'{2{b,c}}},'{a,'{2{b,c}}}},
'{'{a,'{2{b,c}}},'{a,'{2{b,c}}},'{a,'{2{b,c}}} } } */
/* expands to '{'{'{a,'{b,c,b,c}},'{a,'{b,c,b,c}},'{a,'{b,c,b,c}}},
'{'{a,'{b,c,b,c}},'{a,'{b,c,b,c}},'{a,'{b,c,b,c}}}} */
WITH
Replicate operators
can be used to set the values for the exact number of members. The
inner pair of braces
in a replication is removed. Implementations may evaluate assignment
patterns before replication.
struct {int X,Y,Z;} XYZ = '{3{1}};
typedef struct {int a,b[4];} ab_t;
int a,b,c;
ab_t v1[1:0]
[2:0];
v1 = '{2{'{3{a,'{2{b,c}}}}}};
v1 =
'{2{'{3{'{a,'{2{b,c}}}}}}};
/* expands to '{'{3{'{a,{2{b,c}}}}}, '{3{{a,'{2{b,c}}}}}} */
/* expands to '{ '{3{ '{ a, '{2{
b, c }} } }},
'{3{ '{ a, '{2{ b, c }}
} }}
} */
/* expands to '{'{'{a,'{2{b,c}}},'{a,'{2{b,c}}},'{a,'{2{b,c}}}},
'{'{a,'{2{b,c}}},'{a,'{2{b,c}}},'{a,'{2{b,c}}} } } */
/* expands to '{ '{ '{ a, '{2{ b,
c }} },
'{ a, '{2{ b, c }} },
'{ a, '{2{ b, c }} }
},
'{ '{ a, '{2{ b, c }} },
'{ a, '{2{ b, c }} },
'{ a, '{2{ b, c }} }
}
} */
/* expands to '{'{'{a,'{b,c,b,c}},'{a,'{b,c,b,c}},'{a,'{b,c,b,c}}},
'{'{a,'{b,c,b,c}},'{a,'{b,c,b,c}},'{a,'{b,c,b,c}}}}*/
/* expands to '{ '{ '{ a, '{ b, c,
b, c } },
'{ a, '{ b, c, b, c } },
'{ a, '{ b, c, b, c } }
},
'{ '{ a, '{ b, c, b, c } },
'{ a, '{ b, c, b, c } },
'{ a, '{ b, c, b, c } }
}
} */