From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124466 invoked by alias); 21 Sep 2016 17:22:54 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 124431 invoked by uid 89); 21 Sep 2016 17:22:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:595 X-HELO: zimbra.cs.ucla.edu Subject: Re: [PATCH] libio: Add small optimization on fmemopen To: Adhemerval Zanella , libc-alpha@sourceware.org References: <1474466758-26544-1-git-send-email-adhemerval.zanella@linaro.org> From: Paul Eggert Message-ID: <2afbe144-bb78-b657-002a-361fb3220269@cs.ucla.edu> Date: Wed, 21 Sep 2016 17:22:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1474466758-26544-1-git-send-email-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2016-09/txt/msg00385.txt.bz2 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.