From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by sourceware.org (Postfix) with ESMTPS id DE1AA3858CD1 for ; Wed, 5 Jul 2023 08:17:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE1AA3858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2b5c2433134so5813691fa.0 for ; Wed, 05 Jul 2023 01:17:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688545027; x=1691137027; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=QRy1gGIgHJpo/RjFBn29FPxnFJsJNzkFO4PYemLBdZ8=; b=L1Z/zcZP9Oj1wZeJuCOw9B30fuTWuFwk4o/JYxwMDf/rmN3slROU95zzMeqKXrQrxg mcuy+RJOXcsESWOI8/BHQAX6TLc45F6STo4so6VoQeXMdKHCfY6tem2ORvAJPnFJCaim yUdA9WtomrVUP/XKWOlHBzCt93ofej+nRO5AaUMKHizMlb1rExpKn+Cjpb6PUlHeBJp1 U2odI4RXC2piWS6KhfUcVF00q2eftXR21Xnceiqs0GuU87fA5DPNOHXQ5ZIAM0trJpLe COvbNk/HN1qHkmmTmUlY0bTCOitUWxMJ3TL8irr0JNbnoH9ah+yS7hfaB3eMZQOeU1Pk V1kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688545027; x=1691137027; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QRy1gGIgHJpo/RjFBn29FPxnFJsJNzkFO4PYemLBdZ8=; b=erRiualz8evPiEHKIgjxIaDE6Y9IKrZx7+3uHqeesKuc6MWq/CJzqk4mscKxgM1KgS E012LIjaNLFJJWKbhtWHDuJwVxmP17Oiv45GbascDVULsj0lwgJiSFwwlpxti0U0+Btc M8ki9vZeac2ZLJU71X9pivh7L8HCSawaqhYiGIe4ujmfvt2jIzCemj+2B+KSCmId42ea aZnQlIq+wldO4sEsk/AAv+RUsop7y3Mg2rq/2uoW+CmFzqCiSsdex6TlKiMLf/++6PRI YIeyDwN0EUK55B9Alr0CXZJrNa0Ceflj13RGUNCmc+/P399Uh7GlD4znHzm3nk8V1jZz 9Faw== X-Gm-Message-State: ABy/qLa1MqgUDta2DrSLbnlaoRglcI1KnHQqxZJsFMozpu/A8Xnn0dpT zDW/C5LgSmw4kbUS343G2KxJy9ZI62khsIERoIU= X-Google-Smtp-Source: APBJJlFOt14EJAtORRTmCKDFXWBWz7LGBSHheVb7aXmM+l2HzBrmVnwEbNZiJe7Q6jhkQ/iPtFG8LU27VIDlgbwnYWk= X-Received: by 2002:a05:651c:1696:b0:2b6:a840:1502 with SMTP id bd22-20020a05651c169600b002b6a8401502mr616241ljb.9.1688545027067; Wed, 05 Jul 2023 01:17:07 -0700 (PDT) MIME-Version: 1.0 References: <87bkgqvlst.fsf@euler.schwinge.homeip.net> In-Reply-To: <87bkgqvlst.fsf@euler.schwinge.homeip.net> From: Richard Biener Date: Wed, 5 Jul 2023 10:13:44 +0200 Message-ID: Subject: Re: GTY: Explicitly reject 'string_length' option for (fields in) global variables (was: [PATCH] pch: Fix streaming of strings with embedded null bytes) To: Thomas Schwinge Cc: Lewis Hyatt , gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Jul 5, 2023 at 9:51=E2=80=AFAM Thomas Schwinge wrote: > > Hi! > > On 2022-10-18T18:14:54-0400, Lewis Hyatt via Gcc-patches wrote: > > [...] add a new > > GTY option "string_length" so that gt_pch_note_object can be informed t= he > > actual length it ought to use, [...] > > > --- a/gcc/doc/gty.texi > > +++ b/gcc/doc/gty.texi > > @@ -196,7 +196,26 @@ static GTY((length("reg_known_value_size"))) rtx *= reg_known_value; > > Note that the @code{length} option is only meant for use with arrays o= f > > non-atomic objects, that is, objects that contain pointers pointing to > > other GTY-managed objects. For other GC-allocated arrays and strings > > -you should use @code{atomic}. > > +you should use @code{atomic} or @code{string_length}. > > + > > +@findex string_length > > +@item string_length ("@var{expression}") > > + > > +In order to simplify production of PCH, a structure member that is a p= lain > > +array of bytes (an optionally @code{const} and/or @code{unsigned} @cod= e{char > > +*}) is treated specially by the infrastructure. Even if such an array = has not > > +been allocated in GC-controlled memory, it will still be written prope= rly into > > +a PCH. The machinery responsible for this needs to know the length of= the > > +data; by default, the length is determined by calling @code{strlen} on= the > > +pointer. The @code{string_length} option specifies an alternate way t= o > > +determine the length, such as by inspecting another struct member: > > + > > +@smallexample > > +struct GTY(()) non_terminated_string @{ > > + size_t sz; > > + const char * GTY((string_length ("%h.sz"))) data; > > +@}; > > +@end smallexample > > In preparation for another thing I'm working on, OK to push the attached > "GTY: Explicitly reject 'string_length' option for (fields in) global var= iables" > (with pointing to this message)? OK > > Gr=C3=BC=C3=9Fe > Thomas > > > ----------------- > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 2= 01, 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch= =C3=A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellsc= haft: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955