https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120705
Bug ID: 120705
Summary: Assertion failure on Finalizable aspect and
discriminant-dependent String bounds
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: dennis at przytarski dot com
CC: dkm at gcc dot gnu.org
Target Milestone: ---
Created attachment 61662
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61662&action=edit
Reproducer
This code
pragma Ada_2022;
pragma Extensions_Allowed (On);
package Example is
package Z is
type A is abstract tagged limited null record
with Finalizable => (Initialize => Initialize); -- remove
procedure Initialize (this : in out A) is abstract;
type B (l : Natural) is new A with
record
a : String (1 .. l); -- replace l by 3
end record;
overriding
procedure Initialize (this : in out B) is null;
function Make return B is (l => 3, a => "asd");
end Z;
Y : Z.B := Z.Make; -- this line would normally be in a procedure, but it's
here to keep the code short and reproduce the GNAT bug
end Example;
fails with
+===========================GNAT BUG DETECTED==============================+
| 16.0.0 20250618 (experimental) (x86_64-linux-gnu) Assert_Failure
tbuild.adb:722|
| Error detected at example.ads:24:4 |
| Compiling <source> |
The GNAT bug does not occur if either
* the Finalizable aspect is removed from type A, or
* the discriminant l is not used to define the bounds of the String field.