From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 2FF9C3858437 for ; Thu, 18 Aug 2022 09:23:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FF9C3858437 Received: by mail-ej1-x62e.google.com with SMTP id uj29so2210169ejc.0 for ; Thu, 18 Aug 2022 02:23:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=XCbN3c6IsOKCgfrjDidDrn0OWWl2+1dwinYXBj0qPOI=; b=8NQd4cYLu82Iaykv0VThrZuNtTaPfaSQmmtpC23486DbpBbeg2Qizy9dHG6yGuUHmp p68vMX2Xcj9iBUyb0n9PbHnS85RfWgw/LCe1kcEaXLdZXi0OC+1xTTZ+ywkTfugsSREC LBQQqBfnEp2e4J5LFminraYhxjDHDdVBol3VWMOcIZlzy4ogjNaqiwR+5yd0Dnk8VGzZ lTry1Px7Pnc64n39Is58xYpknsHRjrjzk1d4H9k2VLVa3lD6LRISZ+f7vutTg3czGPkp 79KFVB2ECSfmb0yZPR+A/M7J7fbKMMKqiXccsDEb7+B/G3WgK2eLIwB8EQEVf0KGqbTQ 08Fw== X-Gm-Message-State: ACgBeo38kTDB+ji4W4GiB6q+YRpHTxF2M1Cv/5w867+5XFAXsFkRztwH GjDlUTVH5JY5WfcVWHkgHWmQgqGnrKecF7w8P+RxZBVg X-Google-Smtp-Source: AA6agR5Zde1mIU+8fYFE1seKwBPikXrtcKE5VuF7GNL5SmZtFiTUe/pdWLSkVgT9/UDa6Ha7pNrLV9Z/JSBIZ89cy5A= X-Received: by 2002:a17:907:6295:b0:703:92b8:e113 with SMTP id nd21-20020a170907629500b0070392b8e113mr1372475ejc.594.1660814580950; Thu, 18 Aug 2022 02:23:00 -0700 (PDT) MIME-Version: 1.0 References: <3184807.aeNJFYEL58@arcturus> <1825906.tdWV9SEqCh@arcturus> <2251622.ElGaqSPkdT@arcturus> In-Reply-To: <2251622.ElGaqSPkdT@arcturus> From: Richard Biener Date: Thu, 18 Aug 2022 11:22:48 +0200 Message-ID: Subject: Re: [PATCH] Fix bogus -Wstringop-overflow warning in Ada To: Eric Botcazou Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2022 09:23:03 -0000 On Thu, Aug 18, 2022 at 9:54 AM Eric Botcazou wrote: > > > Meh. OK, eventually would need "indirection" through a wide-int then. > > Like > > > > offset_int::from (wi::to_wide (lowbnd), TYPE_SIGN (TREE_TYPE (lowbnd))) > > That would be OK if get_offset_range did the same, but it does not since it > forces a sign-extension whatever the sign of a large type: > > signop sgn = SIGNED; > /* Only convert signed integers or unsigned sizetype to a signed > offset and avoid converting large positive values in narrower > types to negative offsets. */ > if (TYPE_UNSIGNED (type) > && wr[0].get_precision () < TYPE_PRECISION (sizetype)) > sgn = UNSIGNED; > > > I think it should extend according to sing of lowbnd? Or does Ada > > use an unsigned lowbnd to represent a signed value here? At least > > that's what I had issues with with your patch. > > It uses sizetype like everyone else and the signedness was forced on it > because of the POINTER_PLUS_EXPR thing, i.e. it was signed before. Hmm :/ But that means we _should_ force a sign extension but only from ptrofftype_p ()? That is, your test above should maybe read signop sgn = TYPE_SIGN (type); if (ptrofftype_p (type)) sgn = SIGNED; assuming 'type' is the type of lowbnd > -- > Eric Botcazou > >