Patch for uninitialized structures in tests
Steve Ellcey
sje@cup.hp.com
Thu Apr 24 21:50:00 GMT 2008
> They do depend on the initialization values for the following reason.
In fact we don't even need a NaN for some of the tests to fail. Take
gcc.dg/struct/wo_prof_global_var.c for example. The floating point
field b is uninitialized. Let's say it happens to have 3.2 in it. When
we do "p[i].a = p[i].b + 1" The integer field "p[i].a" will wind up with
4 when it gets truncated to an integer value. Then when we compare
"p[i].a != p[i].b + 1" "p[i].a" will be 4 and "p[i].b + 1" will be 4.2.
I still think it wrong for the test to assume that malloced space is
initalized.
>From the C99 standard, Section 7.20.3.3:
The malloc function allocates space for an object whose size is
specified by size and whose value is indeterminate.
Steve Ellcey
sje@cup.hp.com
More information about the Gcc-patches
mailing list