[COMMITTED,17/31] ada: Compiler crash on container aggregate association with nonstatic key choice
| Message ID | 20250911091904.1505690-17-poulhies@adacore.com |
|---|---|
| State | Committed |
| Commit | 767fce326ec142a3d63b5472814ff516e363d8dc |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A186B3858C62 for <patchwork@sourceware.org>; Thu, 11 Sep 2025 09:30:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 821B23858CB6 for <gcc-patches@gcc.gnu.org>; Thu, 11 Sep 2025 09:19:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 821B23858CB6 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 821B23858CB6 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582370; cv=none; b=dlZfZnznTPTkRaPjmbSqLfahny7fYYJ1iCtvWAxUcJaiDFD5IUwQnwsbQZJsx2rCZrNSC7chMqc7+tEhWmWQdgv98gHjQ3kGUuhGQOS7I7jbGLKEK0lhFEg1UbFsblWC8dpvv+UbpBdhytF9O7gkCKp42P/txIqriXygm60YYiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757582370; c=relaxed/simple; bh=KEOviqWatkbxDO0Aa72y5IoE4g+0eWVdrtVJJxQBnQg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=csR7WN/ukEHHBcFmAUDTt+SNWEh876djQD+OMRfWwDWVHanKJoquzXuODA5sQ7kWS49tY1Wl5jrlKtobmC7qKLjxNa7XzuVuTzR7ALdiTpmI7PbI3IfiR6vipHaIB/1ooo+wtX7E0jpsccf4lD+yvuS4szeuZRLpeOlBka2DrpQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 821B23858CB6 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=WLr5quQ7 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-45dfb6cadf3so4418465e9.2 for <gcc-patches@gcc.gnu.org>; Thu, 11 Sep 2025 02:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757582369; x=1758187169; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l6VZFd2Wpv+8ZvVD9LFHPz/4Wnhv9yaUUKmoRpVmpQ0=; b=WLr5quQ723SQGpjJgorQu8xKLRnsLDTFQt9JxwzujV9u6MNgewUEr5483ucjjKURR6 dT3I93DJX51P1PkcTJ82EwlpT06F5NngNoW0GoFJlfSzPYAu3dL7Z410T5ISQnUQfJ5i Pntig3/9NzSfRr0lVu8OtdJOp5jGGVHA6xxP2WblAlrZ2JB6whXU0ucK3thtzvqmaRFE TMnocEmdg/M5Sb7A7HBwumbT8H/A8yrkj+tf86afo6Pt0Gy0IrcnM/JsHM89t2nTpTDj oSBbpRnZ2kRC36AReQNM2SeSSeW3ypz5NasjTClJWj7CYF4ii/XHwyEoOJ44FEdiy9jv 5hJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757582369; x=1758187169; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l6VZFd2Wpv+8ZvVD9LFHPz/4Wnhv9yaUUKmoRpVmpQ0=; b=NU7I9tgcIc4BcINAeOGkDS4mS097tD3mU70gQoMEO3kJ458wcD8da5qVwr/6t6qSHV p3UGjxnvqtCKh5iclNycK6L6VemHsU223az34EnzIOdycY/oLq35S5Kb/8pLYorfioF9 nu5qckbV+9zBdBhkttuqsxrlE/6JGtLa1Mh3KmLMCk4+Z059C1cM0leI/xrrv1bbhTyj hqJMtKp94AJjk15Hbbvk8D1N8nDB2amlJ5Nkjc1INNzFRcARckl2EhCF7aizktCl718+ VGtrqcYqnYbSxXgjNvUL7pgG+mrOBOcKVBjZE5HBN2qJc40z7zQumj8BOxnw9ocCV9pO Vx1w== X-Gm-Message-State: AOJu0YzjHf33B+q2h2Hgg5goAWzvWG/4xbfTHYC690IVKDBjdCng1q/l zTQ2FrVsqBnWUvlMy335vd0d3OmsJQf0YaGiZQ9R4XwiB9Q+025exMkATHHCORt2EdmMP5wFgEL qyDs= X-Gm-Gg: ASbGnctq6Q3fZnT9ksg+SDxpON77AxCv3ATEx0VUNFwQsHAhcYs6+SuxBxPchArXMiQ wWZfh1vz13jTsEv40OpXJ+I+w3ypvansDsHM+atC+/+9CoQB2xqppdHiCTqMtCltuKof7nCZcku rgDLfCoUTMMSJMVhUY8L5cvqO+t5t6+Vi93KYFfGPumTqXGVRI4Yk4HF3gccM5QAOnbNhIvT84u h9xu4Kbaan29l8qc02ZnAvV61c5yjaDoohB+HjMQltdwPzqGfAEUrvdd1QlQXmLZPZkE2B21hY4 67IeDVDQ9oKFXxcnceSC9Xse3LlWkZO0L0QduW2WqIDEL9t0ZRTbhR7MzoqiQVVTCANU7ERlnQ+ psQo9cN+7nYXjUDJtABc1FNb7pMDi29RqjIDNzkFxURMtEV0TlatzrgNeII974oEz4gVhi7LcEU X4SpxL5aGEJ+3aE2FjbZe7fXEsq/jTjI/iNBO7JSq/w03cOutBUXSf1dfGWVg= X-Google-Smtp-Source: AGHT+IF3Lwev0MQYm8Iqtg42oIUhNNGDPRTxgmTq3lh/m8TfXOkkg5pkN4LA7WGnQUt5FxG7GqWVqw== X-Received: by 2002:a05:6000:4283:b0:3e1:734b:5393 with SMTP id ffacd0b85a97d-3e6435551d9mr14946746f8f.28.1757582369115; Thu, 11 Sep 2025 02:19:29 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607cd27dsm1649971f8f.41.2025.09.11.02.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 02:19:28 -0700 (PDT) From: =?utf-8?q?Marc_Poulhi=C3=A8s?= <poulhies@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Gary Dismukes <dismukes@adacore.com> Subject: [COMMITTED 17/31] ada: Compiler crash on container aggregate association with nonstatic key choice Date: Thu, 11 Sep 2025 11:18:49 +0200 Message-ID: <20250911091904.1505690-17-poulhies@adacore.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250911091904.1505690-1-poulhies@adacore.com> References: <20250911091904.1505690-1-poulhies@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
[COMMITTED,01/31] ada: Disable new warning for composite equality ops that can raise Program_Error
|
|
Commit Message
Marc Poulhiès
Sept. 11, 2025, 9:18 a.m. UTC
From: Gary Dismukes <dismukes@adacore.com>
The compiler blows up on a container aggregate with a container element
association that has a key_choice given by a nonstatic key expression.
This happens in the size computation for the aggregate due to calling
Update_Choices with the nonstatic expression. The fix is simply to
condition the call to Update_Choices on whether the choice expression
is static.
gcc/ada/ChangeLog:
* exp_aggr.adb (Build_Container_Aggr_Code.Build_Size_Expr): In the case
of an association with a single choice, only call Update_Choices when
the choice expression is nonstatic.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/exp_aggr.adb | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 34d4f84f95e6..6b4f4a19d1f9 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -6984,7 +6984,9 @@ package body Exp_Aggr is -- Choice is a single discrete value elsif Is_Discrete_Type (Etype (Choice)) then - Update_Choices (Choice, Choice); + if Is_Static_Expression (Choice) then + Update_Choices (Choice, Choice); + end if; Temp_Siz_Exp := Make_Integer_Literal (Loc, 1); Set_Is_Static_Expression (Temp_Siz_Exp);