]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/33631 (auto structure not initialized correctly)
authorRichard Guenther <rguenther@suse.de>
Mon, 4 Feb 2008 22:34:21 +0000 (22:34 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 4 Feb 2008 22:34:21 +0000 (22:34 +0000)
2008-02-04  Richard Guenther  <rguenther@suse.de>

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

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr33631.c [new file with mode: 0644]

index 806fce1438376a245be26074d42ece5db0daba5e..adb51bcbc9e063d9e224375fea34512659ce689a 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-04  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/33631
+       * expr.c (count_type_elements): Give for unions instead of
+       guessing.
+
 2008-02-01  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        Backport:
index c9e2c9510ac6fef2c6603b0a5c3af83b792a0421..a32caddd285a69d69fc4d72fedd4c433d678c667 100644 (file)
@@ -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;
index b00692a5553635bbf934a4d787017b50c973c192..4070878ff0cc9d8e196a4adf4cb428926ae2f41f 100644 (file)
@@ -1,3 +1,8 @@
+2008-02-04  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/33631
+       * gcc.c-torture/execute/pr33631.c: New testcase.
+
 2008-01-31  Andreas Krebbel  <krebbel1@de.ibm.com>
 
        * 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 (file)
index 0000000..840fd0d
--- /dev/null
@@ -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;
+}