https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124606
Bug ID: 124606
Summary: Generic instantiation failure with changed order of
formal parameters
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: leman at mailbox dot org
CC: dkm at gcc dot gnu.org
Target Milestone: ---
Created attachment 64002
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64002&action=edit
a tiny program reproducing the described problem
[This is rather obscure and specific and as such best seen in the attached
example.adb file]
DESCRIPTION:
We are instantiating a generic vector->array conversion function.
The instantiation fails if:
1) the element type of array/vector is a constrained type AND
2) the generic formal parameter for the array type is specified *after* the
`with package Vectors is new...` generic formal parameter for the vector type.
COMPILATION:
```console
$ gnatmake example.adb
gcc -c example.adb
example.adb:46:23: error: component subtype of actual does not match that of
formal "T_Array"
example.adb:46:23: error: instantiation abandoned
gnatmake: "example.adb" compilation error
```
NOTES:
The instantiation succeeds if element type is unconstrained OR the order of
formal parameters is modified.
In short:
* constrained type & array parameter after vector parameter -> failure
* unconstrained type & array parameter after vector parameter -> success
* constrained type & array parameter before vector parameter -> success