This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -Wplacement-new on by default
- From: Jason Merrill <jason at redhat dot com>
- To: Martin Sebor <msebor at gmail dot com>, GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Thu, 10 Dec 2015 15:11:57 -0500
- Subject: Re: -Wplacement-new on by default
- Authentication-results: sourceware.org; auth=none
- References: <5669BDD8 dot 2090800 at gmail dot com>
On 12/10/2015 01:00 PM, Martin Sebor wrote:
Jason,
I just want to make sure we still want the -Wplacement-new option
I added some time ago enabled by default.
I think I had initially intended it to be on because the original
implementation was more permissive and didn't diagnose cases where
(for example) the buffer spanned multiple members of the same struct,
as in the example below. After our discussion of the patch where
you pointed out that C++ is moving in the direction of increased
strictness of aliasing requirements, I changed it to diagnose
those cases.
Can you please confirm that enabling -Wplacement-new by default
is still appropriate?
Thanks
Martin
struct S {
int a;
char b;
} s;
new (&s) char [sizeof s]; // accepted
new (&s.a) char [sizeof s]; // diagnosed
I think it's still appropriate to warn about this by default.
Jason