From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 1198E1F462 for ; Fri, 24 May 2019 08:42:20 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; q=dns; s=default; b=L47A2 8M9O2TLnjIFu1lf9Bw8/yiN89EDv8DaFh06stSebRe8BVE3cTxM9Sb+9Of4O/11L EPdgF0EfKbtARpPePpVPCWknarq+hKsAS1efIg9OHYFLGflRWb9uQjdCQWrU780K ExRT9/0PcsvDOU6rDahQSloUS4WZxVPeASMDck= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type; s=default; bh=Io9NvgyNKbU GXiUOZcKRpzuYeb4=; b=H4wQMmr+SgucT8BcbI8E8g98zi9FFJ8IPdlSmxuNfeh /p2d+FFmWVqQeTN9xut0nZ900zKfj10kw6G0L75Ipv1HRnaTBmI7hssU0XzA8VhV l02a/aMiwa6aFgwhX5SsjCZcx2epyME4XkQr+k7EDMGe4fYGrxT4k4jmGxbNsMBY = Received: (qmail 83789 invoked by alias); 24 May 2019 08:42:17 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 83781 invoked by uid 89); 24 May 2019 08:42:17 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mx1.redhat.com From: Florian Weimer To: Paul Eggert Cc: libc-alpha@sourceware.org Subject: Re: [PATCH] dlfcn: Avoid one-element flexible array in Dl_serinfo References: <87k1ehzf7o.fsf@oldenburg2.str.redhat.com> <437469fe-7622-9021-0b0c-5e4a1cdb8482@cs.ucla.edu> Date: Fri, 24 May 2019 10:42:13 +0200 In-Reply-To: <437469fe-7622-9021-0b0c-5e4a1cdb8482@cs.ucla.edu> (Paul Eggert's message of "Thu, 23 May 2019 15:42:57 -0700") Message-ID: <8736l4utui.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain * Paul Eggert: > On 5/23/19 2:34 AM, Florian Weimer wrote: >> +# ifdef __GNUC__ >> + /* This avoids an unwanted array subscript check by the compiler, >> + while preserving the size of the type. */ >> + __extension__ union >> + { >> + Dl_serpath dls_serpath[0]; /* Actually longer, dls_cnt elements. */ >> + Dl_serpath __dls_serpath_pad[1]; >> + }; >> +# else /* !__GNUC__ */ >> Dl_serpath dls_serpath[1]; /* Actually longer, dls_cnt elements. */ >> +# endif /* !__GNUC__ */ > > Since this is actually a flexible array member, shouldn't we be using > C99's support for that if available, instead? Something like the > attached untested patch, say. We've been using a FLEXIBLE_ARRAY_MEMBER > macro in Gnulib for quite some time to do this sort of thing. This changes the size of the type and is not source-code-compatible. I have not investigated whether the change is still reasonably safe, but usually, wo do not make such changes. Thanks, Florian