From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by sourceware.org (Postfix) with ESMTPS id B78223858CDB for ; Thu, 18 May 2023 12:02:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B78223858CDB 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-x230.google.com with SMTP id 38308e7fff4ca-2af177f12a5so6084761fa.2 for ; Thu, 18 May 2023 05:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684411376; x=1687003376; 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=bM4N+9SyGp/PeLNHOWTGmkojugajEAdUyC2Yel02GKs=; b=JojgY6JAQ3whQY6YrU+QVGePPMA7hynsV3QvDx2CDaLwj7hK0UpX/U2JAUFwhc09Ts Bs8WhWDm5/eWTHxaohGHpLhTGy+tjvbtkfPZ7y8rL88nQycIG4qXnUzDh4LJIVq5De0d wMuqAGDpaft16K1rwWrusrn/1QOyTY9hQcMZpJuIQZCHQUx2uLLgO7a+jQ3ONCVctTpe v3ypWDtDONlUKU521MPLV6Vgd1A3Yv8SZFNxBbb3FLJOFNvLkHQGDxdUEVzeos4DpHzU fZA8qEnctehDWNgZju87RFLNE0zCP7d3w8TLBlu9V6XEO6EIynld84M9jT4DrxzL2rxe /H8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684411376; x=1687003376; 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=bM4N+9SyGp/PeLNHOWTGmkojugajEAdUyC2Yel02GKs=; b=auYMD0i+RTo2FiEKN4wD4L4aZXkRtwqerWhIhqB+Bx6bTTmEAMKWnEFjsArMmBrN6U ugd8GgpgNg6stsW29mLg6AbTApNSh1n0PFP2dqoy7xBJrTfG3fXbAzQ1yjn6l8+OYmJb lMzKScM9Tk0FEm0PDF4Qgmpni8pGHwNUTBzBSvh/0wgcxUpoQ7VdQRQ/9Pj/JGLwPKmX sDWf5e46JaZIxTxFvGgemSkYgW+Y8iN50Hd3UpCouGfeCakCUQjQZy880YziOBCrj6Tb qI3K2t7FeO7VvqAy1xJdtQSyk7r9GNBkvQg+ki3FmVaLkkDjopJMliTP8w0UD+l0ymuH zp1Q== X-Gm-Message-State: AC+VfDyAt8dfO1h4OBjIOhmKcfyVbUYgtsLeozsBlEd9GMaN+llUFFDn luPJhCuXZht+NMUz+tmYCRYp4/Z46We5i7SRAE0= X-Google-Smtp-Source: ACHHUZ46DrTsvuHOkOGPnaAPZyLVBhsA5Z5inSaBe/jEKQeX8xEHWBm5eaL8R5YdbwsZwvwX6q0ZM/24O8EdItZyBzw= X-Received: by 2002:a2e:6e17:0:b0:2ac:826e:c5a with SMTP id j23-20020a2e6e17000000b002ac826e0c5amr11248400ljc.1.1684411375833; Thu, 18 May 2023 05:02:55 -0700 (PDT) MIME-Version: 1.0 References: <4801877.GXAFRqVoOG@fomalhaut> In-Reply-To: <4801877.GXAFRqVoOG@fomalhaut> From: Richard Biener Date: Thu, 18 May 2023 14:02:43 +0200 Message-ID: Subject: Re: [PATCH] Fix internal error on small array with negative lower bound To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.1 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 Thu, May 18, 2023 at 11:51=E2=80=AFAM Eric Botcazou via Gcc-patches wrote: > > Hi, > > Ada supports arrays with negative indices, although the internal index ty= pe is > sizetype like in other languages, which is unsigned. This means that neg= ative > values are represented by very large numbers, which works with a bit of c= are. > The attached test exposes a small loophole in output_constructor_bitfield= . > > Tested on x86-64/Linux, OK for the mainline? Would it be better to use wi::to_uhwi (wi::to_wide (local->index) - wi::to_wide (local->min_index)) to honor the actual sign of the indices? I think nothing forbids frontends= to use a signed TYPE_DOMAIN here? But the difference should be always representable in an unsigned value of course. > > 2023-05-18 Eric Botcazou > > * varasm.cc (output_constructor_bitfield): Call tree_to_uhwi inst= ead > of tree_to_shwi on array indices. Minor tweaks. > > > 2023-05-18 Eric Botcazou > > * gnat.dg/specs/array6.ads: New test. > > -- > Eric Botcazou