From: Richard Guenther Date: Mon, 4 Feb 2008 22:34:21 +0000 (+0000) Subject: re PR middle-end/33631 (auto structure not initialized correctly) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4647fb8082fc1293128be784fd703c0bbe3520bd;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: r132101 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 806fce143837..adb51bcbc9e0 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-01 Kaveh R. Ghazi Backport: diff --git a/gcc/expr.c b/gcc/expr.c index c9e2c9510ac6..a32caddd285a 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -4614,14 +4614,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 b00692a55536..4070878ff0cc 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-01-31 Andreas Krebbel * gcc.dg/tf_to_di-1.c: New testcase. 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; +}