re PR middle-end/33631 (auto structure not initialized correctly)
authorRichard Guenther <rguenther@suse.de>
Mon, 4 Feb 2008 21:18:32 +0000 (21:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 4 Feb 2008 21:18:32 +0000 (21:18 +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: r132096

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

index 1665f9e1afa41ea0ce133ad19a2d8b71d97dda27..4f81c248b227cdd5f441069b2a3e78bdbe753c39 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-04  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/35043
index 53cb3eb9d2cb9ddfe19b4bf8e670a5780ba8f6a8..ade0396f81752f25f7e8b7a9075263a97a4ad02c 100644 (file)
@@ -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;
index 1be9baf30c6af41b43a2f6b770c3459929c2219c..d1b8a5d0ee8bd92862f04506da67017bd378eea5 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-02-04  Richard Guenther  <rguenther@suse.de>
 
        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 (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;
+}