On 02/16/2016 05:55 PM, Martin Sebor wrote:
> I think the new text deserves a new heading of its own rather than
> being added under the existing "Stricter flexible array member rules."
> (The "Finally..." part changed by the patch still applies to the
> flexible array members.)
> 
> Martin

Hi Martin.

Thanks for the nit, fixed in v2.

Ready to be installed?
Martin
Index: htdocs/gcc-6/porting_to.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/porting_to.html,v
retrieving revision 1.14
diff --unified -r1.14 porting_to.html
--- htdocs/gcc-6/porting_to.html	14 Feb 2016 13:13:43 -0000	1.14
+++ htdocs/gcc-6/porting_to.html	17 Feb 2016 14:20:13 -0000
@@ -324,6 +324,52 @@
 <tt>-fabi-version</tt> or <tt>-Wabi</tt> option to disable or warn about.
 </p>
 
+<h3>More aggressive optimization of <code>-flifetime-dse</code></h3>
+
+<p>
+The C++ compiler (with enabled <code>-flifetime-dse</code>)
+has been more aggressive in dead-store elimination in situations where
+a memory store to a location precedes a constructor to the
+memory location. Described situation can be commonly found in programs
+which zero a memory that is eventually passed to a placement new operator:
+
+<pre><code>
+#include &lt;stdlib.h&gt;
+#include &lt;string.h&gt;
+#include &lt;assert.h&gt;
+
+struct A
+{
+  A () {}
+  void *operator new (size_t s)
+  {
+    void *ptr = malloc (s);
+    memset (ptr, 0, s);
+    return ptr;
+  }
+
+  int value;
+};
+
+A *
+__attribute__ ((noinline))
+build (void)
+{
+  return new A ();
+}
+
+int main()
+{
+  A *a =  build ();
+  assert (a-&gt;value == 0); /* Use of uninitialized value */
+  free (a);
+}
+</code></pre>
+
+If the program cannot be fixed to remove the undefined behavior then
+the option <code>-fno-lifetime-dse</code> can be used to disable
+this optimization.
+
 <h2>-Wmisleading-indentation</h2>
 <p>
 A new warning <code>-Wmisleading-indentation</code> was added

Reply via email to