-Wplacement-new on by default

Jason Merrill jason@redhat.com
Thu Dec 10 20:12:00 GMT 2015


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



More information about the Gcc mailing list