Re: [PATCH] tweak -Wplacement-new to fix #69662

2016-02-05 Thread Jason Merrill
On 02/05/2016 11:41 AM, Martin Sebor wrote: But since GCC does allow global/static objects of structs with flexible array members to be initialized, and (presumably) will continue to even after the above is rejected in C++, the code in the patch that detects overflowing such variables will contin

Re: [PATCH] tweak -Wplacement-new to fix #69662

2016-02-05 Thread Martin Sebor
struct A { int i, ar[]; }; int main() { int k = 24; struct A a = { 1, 2, 3, 4 }; int j = 42; return a.ar[1]; } G++ accepts this testcase and happily puts k and j in the same stack slots as elements of a.ar[], while GCC rejects it. We shouldn't accept it. In any case, we should u

Re: [PATCH] tweak -Wplacement-new to fix #69662

2016-02-05 Thread Jason Merrill
On 02/04/2016 04:35 PM, Martin Sebor wrote: On 02/04/2016 02:10 PM, Jason Merrill wrote: On 02/04/2016 03:22 PM, Martin Sebor wrote: + /* Refers to the declared object that constains the subobject referenced + by OPER. When the object is initialized, makes it possible to determine + t

Re: [PATCH] tweak -Wplacement-new to fix #69662

2016-02-04 Thread Martin Sebor
On 02/04/2016 02:10 PM, Jason Merrill wrote: On 02/04/2016 03:22 PM, Martin Sebor wrote: + /* Refers to the declared object that constains the subobject referenced + by OPER. When the object is initialized, makes it possible to determine + the actual size of a flexible array member use

Re: [PATCH] tweak -Wplacement-new to fix #69662

2016-02-04 Thread Jason Merrill
On 02/04/2016 03:22 PM, Martin Sebor wrote: + /* Refers to the declared object that constains the subobject referenced + by OPER. When the object is initialized, makes it possible to determine + the actual size of a flexible array member used as the buffer passed + as OPER to placem

[PATCH] tweak -Wplacement-new to fix #69662

2016-02-04 Thread Martin Sebor
The attached patch implements the changes to the warning we discussed in IRC yesterday. With the patch GCC is by default silent about the test case in bug 69662 and diagnoses it only with -Wplacement-new=2. Arrays of other sizes and statically allocated objects are diagnosed as before. Tested o