From: csmith-bugs-bounces@flux.utah.edu [mailto:csmith-bugs-bounces@flux.utah.edu] On Behalf Of Chucky Ellison
Sent: Tuesday, July 19, 2011 3:58 PM
To: csmith-bugs@flux.utah.edu
Subject: [csmith-bugs] --check-global option causes all fields of a union to be printed
Hi everybody,
I'm using git version: 7d6fae9
The --check-global causes all fields of unions to be printed, when this is often not totally defined.
N1256, 6.2.6.1:7 says: "When a value is stored in a member of an object of union type, the bytes of the object representation that do not correspond to that member but do correspond to other members take unspecified values."
For example, `csmith --check-global -s 50000`
union U0 {
volatile uint32_t f0;
const volatile int64_t f1;
uint8_t f2;
volatile int32_t f3;
};
printf("checksum g_2[0][0][0].f0 = %u\n", g_2[0][0][0].f0);
printf("checksum g_2[0][0][0].f1 = %lld\n", g_2[0][0][0].f1);
printf("checksum g_2[0][0][0].f2 = %u\n", g_2[0][0][0].f2);
printf("checksum g_2[0][0][0].f3 = %d\n", g_2[0][0][0].f3);
In this program, g_2 is global, and is never assigned to except through the initializer. Since initialization of unions works on the first field only (6.7.8:10 "if it is a union, the first named member is initialized ..."), some of the bytes of f1 are never initialized or set to 0. This makes the output of the program at least unspecified.
I didn't check, but if you are using f1 in the checksum calculation when not using --check-global, then that too would be unspecified.
-Chucky