public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	Paul Eggert <eggert@cs.ucla.edu>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH] libio: Add small optimization on fmemopen
Date: Wed, 21 Sep 2016 18:23:00 -0000	[thread overview]
Message-ID: <708fc89d-fbb9-cb20-9ee6-079013baf63b@redhat.com> (raw)
In-Reply-To: <03eb21f7-6979-62eb-0fe8-34ea35b0c7d6@linaro.org>

On 09/21/2016 08:17 PM, Adhemerval Zanella wrote:
>
>
> On 21/09/2016 14:22, Paul Eggert wrote:
>> On 09/21/2016 07:05 AM, Adhemerval Zanella wrote:
>>> +      clen += len;
>>
>> That might cause problems , as the C standard says you can't access a flexible array member past the last byte that is properly aligned for the containing structure, and GCC relies on this when generating code (see GCC bug 66661). One way to work around the problem is to change the earlier:
>>
>> +  size_t clen = sizeof (fmemopen_cookie_t);
>>
>> to:
>>
>> +  size_t clen = sizeof (fmemopen_cookie_t) + _Alignof (fmemopen_cookie_t) - 1;
>>
>> This may overallocate a bit, but that's OK here.
>>
>
> Thanks for pointing this out, I think this is the safe approach regarding
> Florian comment #10 and #11.  I will change it.

Please don't, it's a defect in the standard (and GCC"s Address Sanitizer 
has a bug as well).

Florian

  reply	other threads:[~2016-09-21 18:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-21 14:06 Adhemerval Zanella
2016-09-21 14:57 ` Florian Weimer
2016-09-21 18:18   ` Adhemerval Zanella
2016-09-21 17:22 ` Paul Eggert
2016-09-21 18:17   ` Adhemerval Zanella
2016-09-21 18:23     ` Florian Weimer [this message]
2016-09-21 18:26       ` Adhemerval Zanella
2016-09-21 18:43         ` Paul Eggert
2016-09-21 18:47           ` Florian Weimer
2016-09-21 18:57             ` Paul Eggert
2016-09-21 19:27               ` Florian Weimer
2016-09-21 20:16                 ` Adhemerval Zanella
2016-09-21 20:42                 ` Paul Eggert
2016-09-23  5:17           ` Ondřej Bílka
2016-09-23  5:34             ` Florian Weimer
2016-09-23 18:14               ` Ondřej Bílka
2016-09-23 20:38                 ` Florian Weimer
2016-09-23 18:29             ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=708fc89d-fbb9-cb20-9ee6-079013baf63b@redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).