From: Richard Guenther Date: Mon, 4 Feb 2008 22:03:09 +0000 (+0000) Subject: re PR middle-end/33631 (auto structure not initialized correctly) X-Git-Tag: prereleases/gcc-4.2.4-rc1~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f59a43f731303f90d7931debe29c9d2be55ba41a;p=thirdparty%2Fgcc.git re PR middle-end/33631 (auto structure not initialized correctly) 2008-02-04 Richard Guenther PR middle-end/33631 * expr.c (count_type_elements): Give for unions instead of guessing. * gcc.c-torture/execute/pr33631.c: New testcase. From-SVN: r132097 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c8ef22c88c6..c12325d3c5c4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-02-04 Richard Guenther + + PR middle-end/33631 + * expr.c (count_type_elements): Give for unions instead of + guessing. + 2008-02-04 Andreas Krebbel * config/s390/fixdfdi.h (__fixunstfdi, __fixtfdi): Rearrange diff --git a/gcc/expr.c b/gcc/expr.c index 9ef151eeb0c2..23b80b074057 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -4779,14 +4779,7 @@ count_type_elements (tree type, bool allow_flexarr) case UNION_TYPE: case QUAL_UNION_TYPE: - { - /* Ho hum. How in the world do we guess here? Clearly it isn't - right to count the fields. Guess based on the number of words. */ - HOST_WIDE_INT n = int_size_in_bytes (type); - if (n < 0) - return -1; - return n / UNITS_PER_WORD; - } + return -1; case COMPLEX_TYPE: return 2; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6e1138acd48f..a7f3ba0e4f12 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-02-04 Richard Guenther + + PR middle-end/33631 + * gcc.c-torture/execute/pr33631.c: New testcase. + 2008-02-04 Daniel Franke PR fortran/34661 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr33631.c b/gcc/testsuite/gcc.c-torture/execute/pr33631.c new file mode 100644 index 000000000000..840fd0dc482c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr33631.c @@ -0,0 +1,14 @@ +typedef union +{ + int __lock; +} pthread_mutex_t; + +extern void abort (void); + +int main() +{ + struct { int c; pthread_mutex_t m; } r = { .m = 0 }; + if (r.c != 0) + abort (); + return 0; +}