2017-10-21 23:40:19 +00:00
|
|
|
/* Deviance Test 4.6.7.1: Ensure illegal initialization of unions is detected */
|
|
|
|
|
2022-10-17 22:50:42 +00:00
|
|
|
int printf(const char *, ...);
|
|
|
|
|
2017-10-21 23:40:19 +00:00
|
|
|
union U1 { int i;
|
|
|
|
long L;
|
|
|
|
char ch [5]; };
|
|
|
|
|
|
|
|
union U1 u1 = "hey, you!"; /* init. must be valid for only 1st type */
|
|
|
|
static union U1 u2 = &u1.i;
|
|
|
|
|
|
|
|
union U1 u3 = { 5, 6, "a", 2, 3 }; /* too many values */
|
|
|
|
static union U1 u4 = { 2, 4, 6.0 };
|
|
|
|
|
|
|
|
|
2022-10-17 22:50:42 +00:00
|
|
|
int main (void)
|
2017-10-21 23:40:19 +00:00
|
|
|
{
|
|
|
|
int i = 5;
|
|
|
|
|
|
|
|
auto union U1 u5 = { "abb" }; /* init. must be valid for only 1st type */
|
|
|
|
static union U1 u6 = { &i };
|
|
|
|
union U1 u7 = { 5, 7, 8.8 }; /* too many values */
|
|
|
|
|
|
|
|
printf ("Failed Deviance Test 4.6.7.1\n");
|
|
|
|
}
|