Re: [PATCH] flexmember: port better to GCC + valgrind

2016-09-07 Thread Jim Meyering
On Wed, Sep 7, 2016 at 2:03 AM, Paul Eggert wrote: > With a char[] flexible array member in a struct with nontrivial > alignment, GCC-generated code can access past the end of the > array, because GCC assumes there are padding bytes to get the > struct aligned. So the common idiom of malloc (offs

[PATCH] flexmember: port better to GCC + valgrind

2016-09-07 Thread Paul Eggert
With a char[] flexible array member in a struct with nontrivial alignment, GCC-generated code can access past the end of the array, because GCC assumes there are padding bytes to get the struct aligned. So the common idiom of malloc (offsetof (struct s, m), n) does not properly allocate an n-byte