From: Richard Guenther Date: Mon, 4 Feb 2008 21:18:32 +0000 (+0000) Subject: re PR middle-end/33631 (auto structure not initialized correctly) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=22199fd25dc76dd3c05d935b07761501911dad37;p=gcc.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: r132096 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1665f9e1afa..4f81c248b22 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 Richard Guenther PR middle-end/35043 diff --git a/gcc/expr.c b/gcc/expr.c index 53cb3eb9d2c..ade0396f817 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -4975,14 +4975,7 @@ count_type_elements (const_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 1be9baf30c6..d1b8a5d0ee8 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 Richard Guenther PR middle-end/35043 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 00000000000..840fd0dc482 --- /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; +}