[PATCH] libio: Add small optimization on fmemopen
Paul Eggert
eggert@cs.ucla.edu
Wed Sep 21 20:42:00 GMT 2016
On 09/21/2016 12:27 PM, Florian Weimer wrote:
> _Alignas is used only to demonstrate the issue more clearly.
>
That's not clear to me. Yes, _Alignas does make the issue pop out more.
However, the problem with the proposed fmemopen code has to do with
allocating flexible arrays via malloc (a fairly common practice),
whereas the problem illustrated by GCC bug 66661 comment 12 has to do
with static allocation of flexible array members (a rarely used feature).
As I understand it, comment 12 argues that GCC should not be able to
assume that an object's size is a multiple of its alignment. That's a
steep uphill climb, I'm afraid, as GCC is riddled with that assumption,
it would be painful to remove it, and the resulting benefit would be so
trivial that I'm afraid it would not be worth the effort. If there's a
bug in the abovementioned rarely used feature, surely it can be fixed
without having to alter GCC's fundamental assumption that size is a
multiple of alignment.
> glibc currently does not compile with Address Sanitizer anyway
It's not just Address Sanitizer, right? valgrind has a similar issue.
More information about the Libc-alpha
mailing list