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 continue to serve its purpose.
Good point.
+@item -Wplacement-new=1 +This is the default warning level of @option{-Wplacement-new}. At this +level the warning is not issued for some strictly invalid constructs that +GCC allows as extensions for compatibility with legacy code. For example, +the following invalid @code{new} expression is not diagnosed at this level. +@smallexample +struct S @{ int n, a[1]; @}; +S *s = (S *)malloc (sizeof *s + 31 * sizeof s->a[0]); +new (s->a)int [32](); +@end smallexample
I'd say "undefined" rather than "invalid" here. OK with that change. Jason