]> 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:03:09 +0000 (22:03 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 4 Feb 2008 22:03:09 +0000 (22:03 +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: r132097

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

index 8c8ef22c88c66ba28f98e9dfc25197b7a89a03eb..c12325d3c5c45b6aedf1357fa72f388c56981fba 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  Andreas Krebbel  <krebbel1@de.ibm.com>
 
        * config/s390/fixdfdi.h (__fixunstfdi, __fixtfdi): Rearrange
index 9ef151eeb0c2eb68645242a324b1f0c25ef242b8..23b80b074057de7fedaed3e2fe0449088bf7e196 100644 (file)
@@ -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;
index 6e1138acd48fbaefc6c5c95e9ff53245aa5f953f..a7f3ba0e4f12ae1f18287c803d895ab4afc39b19 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  Daniel Franke  <franke.daniel@gmail.com>
 
        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 (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;
+}