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 2E6291F462 for ; Mon, 3 Jun 2019 07:59:17 +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:subject:references:date:in-reply-to :message-id:mime-version:content-type; q=dns; s=default; b=O3h/m qUF1QxibxTL717AeJj2F/Ltd5qj39MAJASJWsLdi7NODq0rBYYPWERuKniyydLiM y/Rmbs3HP7SoCq1PAoQdRcFX+ESoywJbweJ86NGAPoKb1m3iyoq2oH3dy0tl4q/k ajybqDG00sKhLaCp19xBZcA4YPt+Ugbo7hsTGo= 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:subject:references:date:in-reply-to :message-id:mime-version:content-type; s=default; bh=6Hyo3JKVq5Y dBUJlW6uap1Njm0w=; b=JgeCYWOL2PPmUTJdvfb7QCEzinCT/KD+EG6dWDGMbJU fy7qedUSTvCvTSZv24lVJDIs/dfqSS9YeHx4Ju+neIbTxkeUgpgO7PQuGc0q8sKi wd9eiOKSpN110kBA0EbPcQBzUuSEjKxmslMNmv23/UPMhTCJUUV3jrmrNDkNXUTA = Received: (qmail 20260 invoked by alias); 3 Jun 2019 07:59:14 -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 19655 invoked by uid 89); 3 Jun 2019 07:59:14 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mx1.redhat.com From: Florian Weimer To: 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> <8736l4utui.fsf@oldenburg2.str.redhat.com> <87imtvhg7w.fsf@oldenburg2.str.redhat.com> Date: Mon, 03 Jun 2019 09:59:10 +0200 In-Reply-To: <87imtvhg7w.fsf@oldenburg2.str.redhat.com> (Florian Weimer's message of "Mon, 27 May 2019 21:04:03 +0200") Message-ID: <877ea3aylt.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain * Florian Weimer: > diff --git a/dlfcn/dlfcn.h b/dlfcn/dlfcn.h > index 896ad6fc9b..7107b3ea9a 100644 > --- a/dlfcn/dlfcn.h > +++ b/dlfcn/dlfcn.h > @@ -180,7 +180,19 @@ typedef struct > { > size_t dls_size; /* Size in bytes of the whole buffer. */ > unsigned int dls_cnt; /* Number of elements in `dls_serpath'. */ > +# ifdef __GNUC__ > + /* The zero-length array avoids an unwanted array subscript check by > + the compiler, while the surrounding anonymous union preserves the > + historic size of the type. At the time of writing, GNU C does > + not support structs with flexible array members in unions. */ > + __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__ */ > } Dl_serinfo; > #endif /* __USE_GNU */ > It turns out that GCC 2.7.2.3 treats this anonymous union as a type declaration and ignores it. I will try to come up with the appropriate __GNUC_PREREQ conditional. (Don't get the wrong idea; we do not test regularly against older GCC versions.) Thanks, Florian