Skip to content

GNAT bug when using in out parameter in advanced array aggregates #54

@ec-c

Description

@ec-c

Hello,

following minimal viable code crashes with llvm-gnatmake but not with gnatmake (gcc-15). I believe that the error is caused by the in out P parameter in the Create function. llvm-gnat was built with last commit being a5efb9da029cfae00e5d668d073dec66f5f52229 (Tue Mar 25 09:05:06 2025 +0000).

pragma Ada_2022;

procedure Main is

   type Test_T (X : Natural) is tagged limited null record;
   type Pointer is not null access all Test_T;

   generic
      with function Create (P : in out Integer) return Pointer;
   package Test is
      type Pointers is array (Positive range <>) of Pointer;
      function Get return Pointers;
   end Test;

   package body Test is
      function Get return Pointers is
         P : Integer := 1;
      begin
         return [for I in 1 .. 3 => Create (P)]; -- crashes here because of "in out P"?
      end Get;
   end Test;

begin
   null;
end Main;

gnatmake ↓

> gnatmake --version
GNATMAKE 15.0.1 20250329 (experimental)
Copyright (C) 1995-2025, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> gnatmake main.adb
gcc -c main.adb
gnatbind -x main.ali
gnatlink main.ali
> ./main

llvm-gnatmake ↓

> llvm-config --version
16.0.6
> llvm-gcc --version
llvm-gcc 15
Copyright (C) 2018-2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
> llvm-gnatmake --version
GNATMAKE 1.0
Copyright (C) 1995-2025, Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

> llvm-gnatmake main.adb
llvm-gcc -c main.adb
+===========================GNAT BUG DETECTED==============================+
| 1.0 (aarch64-apple-darwin24.3.0) Assert_Failure predicate failed at sem_util.adb:2934|
| Error detected at main.adb:19:17                                         |
| Compiling main.adb                                                       |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .              |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact command that you entered.                              |
| Also include sources listed below.                                       |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

main.adb

compilation abandoned
llvm-gnatmake: "main.adb" compilation error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions