This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wplacement-new on by default


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]