From: "Martin Liška" <mliska@suse.cz>
To: Martin Sebor <msebor@gmail.com>, GCC Patches <gcc-patches@gcc.gnu.org>
Cc: jason@redhat.com, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [wwwdocs] Describe behavior of -flifetime-dse in class constructors
Date: Wed, 17 Feb 2016 14:21:00 -0000 [thread overview]
Message-ID: <56C481D3.8000902@suse.cz> (raw)
In-Reply-To: <56C35470.3060700@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 369 bytes --]
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
[-- Attachment #2: porting_6-lifetime-dse_v2.patch --]
[-- Type: text/x-patch, Size: 1598 bytes --]
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 <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+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->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
next prev parent reply other threads:[~2016-02-17 14:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 14:55 Martin Liška
2016-02-16 14:59 ` Kyrill Tkachov
2016-02-16 16:55 ` Martin Sebor
2016-02-17 14:21 ` Martin Liška [this message]
2016-02-17 14:23 ` Jakub Jelinek
2016-02-17 15:01 ` Martin Liška
2016-02-25 10:01 ` Martin Liška
2016-02-25 10:07 ` Markus Trippelsdorf
2016-02-25 10:11 ` Markus Trippelsdorf
2016-06-20 10:30 ` Gerald Pfeifer
2016-06-20 10:34 ` Gerald Pfeifer
2016-02-19 4:52 ` Jan Hubicka
2016-02-25 11:22 ` Martin Liška
2016-02-28 21:43 ` Gerald Pfeifer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56C481D3.8000902@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=jason@redhat.com \
--cc=msebor@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).