From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id F214D3858CDA for ; Fri, 19 Aug 2022 07:30:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F214D3858CDA Received: by mail-ed1-x52a.google.com with SMTP id w3so4644969edc.2 for ; Fri, 19 Aug 2022 00:30:26 -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=TrLD9RjNkCvaHtLMHRuxu0X3TTY/PovLrPa3O/Ll/bU=; b=d10L0eA/FRDyY8uDeExqfBK7sZKDKc61dPxRDAcsTlNzozyL8ySF4Wjd28n05rNbyR nWmeL1+gALjCyML/WJgPirmEceqhhEHPpNGe1rgImXQRBqWNnLgmPa5es9kdu0mJ+kd5 JIgKqsed2vDwIdt3IA6x1+q+6D7rZMwK6a3+K6k5b+gVB+OVx87BEjvH/pW8tkD3RAvl 3uiAO1M0gRwFdQUr2nNut/FDZoO5sDHH3tN9lRzzmAXIHxLHBJlwF1Fbgg6o0RZi3uH4 o92V8DaZRQUXwKLfkURkztvopJxwxqouIkYcRLURV0WDwbneD2fDim9KGU6D1jNzwYod s90w== X-Gm-Message-State: ACgBeo0JbxVyBLoAJ8IsKNBncBRmHIVS71TnmHrUIkwAc1aDoWs78a3L FoeR8oZDfqnnGxfvKrLrZUI950gWzbrHbqhXnA0= X-Google-Smtp-Source: AA6agR4YbXei0O1riOxLUB6A2iseHPnkUKmb9q+nVD9JlGcntXQYJRvwVfXYg8b4Jc3WR5USxzxygcCfTHV0LDmOPuA= X-Received: by 2002:a05:6402:1f02:b0:445:f674:eac0 with SMTP id b2-20020a0564021f0200b00445f674eac0mr4913902edb.370.1660894225698; Fri, 19 Aug 2022 00:30:25 -0700 (PDT) MIME-Version: 1.0 References: <3184807.aeNJFYEL58@arcturus> <2251622.ElGaqSPkdT@arcturus> <3120260.5fSG56mABF@arcturus> In-Reply-To: <3120260.5fSG56mABF@arcturus> From: Richard Biener Date: Fri, 19 Aug 2022 09:30:13 +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=-2.0 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: Fri, 19 Aug 2022 07:30:28 -0000 On Thu, Aug 18, 2022 at 4:46 PM Eric Botcazou wrote: > > > 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 > > Yes, that's essentially equivalent to what get_offset_range does, but I'm not > sure why having two slightly different ways of doing it would be better than a > single one here, Maybe replace the call to get_precision in both places with > TYPE_PRECSION (type) then? I wasn't aware of the copy in get_offset_range. To cite: wide_int wr[2]; if (!get_range (x, stmt, wr, rvals)) return false; 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; r[0] = offset_int::from (wr[0], sgn); r[1] = offset_int::from (wr[1], sgn); I guess the main issue here is that the machinery converts to offset_int prematurely and thus needs to do it even when it's not clear in what context (POINTER_PLUS_EXPR offset or not) it is used. The code unfortunately is a bit of a mess and I'm not too familiar with it. I'm OK with your original patch, given the above it's consistent (even if maybe broken). Thanks, Richard. > > -- > Eric Botcazou > > >