From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Bob Duff <duff@adacore.com>
Subject: [COMMITTED] ada: Compiler crash on early alignment clause
Date: Tue, 7 Nov 2023 10:20:45 +0100 [thread overview]
Message-ID: <20231107092045.3906982-1-poulhies@adacore.com> (raw)
From: Bob Duff <duff@adacore.com>
This patch fixes a bug: if "for T'Alignment use..." is followed
by "for T use (<enum rep>);" the compiler crashes. A workaround is
to move the alignment clause after the enumeration rep clause.
gcc/ada/
* sem_ch13.ads (Set_Enum_Esize): Do not set alignment.
* sem_ch13.adb (Set_Enum_Esize): Do not set alignment. Archaeology
seems to show that this line of code dates from when "Alignment =
0" meant "the Alignment is not known at compile time" and "the
Alignment is not yet known at compile time" as well as "the
Alignment is zero". In any case, it seems to be unnecessary, and
in this case harmful, because gigi would crash. Alignment_Clause
is set (because there is one), so gigi would query the Alignment,
but Alignment was destroyed.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/sem_ch13.adb | 2 --
gcc/ada/sem_ch13.ads | 3 +--
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 5747ee9c539..302fab74757 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -17381,8 +17381,6 @@ package body Sem_Ch13 is
Sz : Unat;
begin
- Reinit_Alignment (T);
-
-- Find the minimum standard size (8,16,32,64,128) that fits
Lo := Enumeration_Rep (Entity (Type_Low_Bound (T)));
diff --git a/gcc/ada/sem_ch13.ads b/gcc/ada/sem_ch13.ads
index 1386096535e..555d302fb10 100644
--- a/gcc/ada/sem_ch13.ads
+++ b/gcc/ada/sem_ch13.ads
@@ -79,8 +79,7 @@ package Sem_Ch13 is
procedure Set_Enum_Esize (T : Entity_Id);
-- This routine sets the Esize field for an enumeration type T, based
-- on the current representation information available for T. Note that
- -- the setting of the RM_Size field is not affected. This routine also
- -- initializes the alignment field to zero.
+ -- the setting of the RM_Size field is not affected.
Unknown_Minimum_Size : constant Nonzero_Int := -1;
--
2.42.0
reply other threads:[~2023-11-07 9:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231107092045.3906982-1-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=duff@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).