public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4013] ada: Crash on applying 'Pos to expression of a type derived from a formal type Date: Mon, 14 Nov 2022 13:51:43 +0000 (GMT) [thread overview] Message-ID: <20221114135143.CF65F3858438@sourceware.org> (raw) https://gcc.gnu.org/g:90b9052e0b5df49d6c298c4706978135d2af2a86 commit r13-4013-g90b9052e0b5df49d6c298c4706978135d2af2a86 Author: Gary Dismukes <dismukes@adacore.com> Date: Wed Nov 2 19:02:34 2022 -0400 ada: Crash on applying 'Pos to expression of a type derived from a formal type The compiler crashes when trying to do a static check for a range violation in a type conversion of a Pos attribute applied to a prefix of a type derived from a generic formal discrete type. This optimization was suppressed in the case of formal types, because the upper bound may not be known, but it also needs to be suppressed for types derived from formal types. gcc/ada/ * checks.adb (Apply_Type_Conversion_Checks): Apply Root_Type to the type of the prefix of a Pos attribute when checking whether the type is a formal discrete type. Diff: --- gcc/ada/checks.adb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 96876672871..2a45f4d49b0 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -3789,13 +3789,14 @@ package body Checks is -- Universal_Integer. So in numeric conversions it is usually -- within range of the target integer type. Use the static -- bounds of the base types to check. Disable this optimization - -- in case of a generic formal discrete type, because we don't - -- necessarily know the upper bound yet. + -- in case of a descendant of a generic formal discrete type, + -- because we don't necessarily know the upper bound yet. if Nkind (Expr) = N_Attribute_Reference and then Attribute_Name (Expr) = Name_Pos and then Is_Enumeration_Type (Etype (Prefix (Expr))) - and then not Is_Generic_Type (Etype (Prefix (Expr))) + and then + not Is_Generic_Type (Root_Type (Etype (Prefix (Expr)))) and then Is_Integer_Type (Target_Type) then declare
reply other threads:[~2022-11-14 13:51 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=20221114135143.CF65F3858438@sourceware.org \ --to=dkm@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).