gcc:
PR tree-optimization/63841
* tree.c (initializer_zerop): A clobber does not zero initialize.
gcc/testsuite:
PR tree-optimization/63841
* g++.dg/tree-ssa/pr63841.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@217505
138bc75d-0d04-0410-961f-
82ee72b054a4
+2014-11-13 Teresa Johnson <tejohnson@google.com>
+
+ PR tree-optimization/63841
+ * tree.c (initializer_zerop): A clobber does not zero initialize.
+
2014-11-13 Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
* optabs.c (prepare_operand): Gracefully fail if the mode of X
+2014-11-13 Teresa Johnson <tejohnson@google.com>
+ PR tree-optimization/63841
+ * g++.dg/tree-ssa/pr63841.C: New test.
+
2014-11-13 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/forwprop-28.c: Adjust.
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include <cstdio>
+#include <string>
+
+std::string __attribute__ ((noinline)) comp_test_write() {
+ std::string data;
+
+ for (int i = 0; i < 2; ++i) {
+ char b = 1 >> (i * 8);
+ data.append(&b, 1);
+ }
+
+ return data;
+}
+
+std::string __attribute__ ((noinline)) comp_test_write_good() {
+ std::string data;
+
+ char b;
+ for (int i = 0; i < 2; ++i) {
+ b = 1 >> (i * 8);
+ data.append(&b, 1);
+ }
+
+ return data;
+}
+
+int main() {
+ std::string good = comp_test_write_good();
+ printf("expected: %hx\n", *(short*)good.c_str());
+
+ std::string bad = comp_test_write();
+ printf("got: %hx\n", *(short*)bad.c_str());
+
+ return good != bad;
+}
{
unsigned HOST_WIDE_INT idx;
+ if (TREE_CLOBBER_P (init))
+ return false;
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (init), idx, elt)
if (!initializer_zerop (elt))
return false;