So this is happening to me, here is a minimal example. Sadly, it requires both spec and body. Note that the library must be generic and the instantiation in the body for the error to be reported; otherwise everything works still being Preelaborate
(either non-generic lib or instance in spec).
This is with GNAT 10 to 14.
generic
package Bug with Preelaborate is
type Any is tagged private;
function Make return Any;
private
type Any is tagged null record;
end Bug;
with Ada.Containers.Indefinite_Vectors;
package body Bug is
function Make return Any is (null record);
package Vectors is new Ada.Containers.Indefinite_Vectors
(Positive, Any'Class);
end Bug;
The stream of errors at the instantiation point is:
bug.adb:7:04: error: instantiation error at a-coinve.ads:541
bug.adb:7:04: error: non-static constant in preelaborated unit
bug.adb:7:04: error: instantiation error at a-coinve.ads:541
bug.adb:7:04: error: "T_Check" is not a static constant (RM 4.9(5))
bug.adb:7:04: error: instantiation error at a-conhel.ads:88
bug.adb:7:04: error: instantiation error at a-coinve.ads:407
bug.adb:7:04: error: non-static constant in preelaborated unit
bug.adb:7:04: error: instantiation error at a-conhel.ads:88
bug.adb:7:04: error: instantiation error at a-coinve.ads:407
bug.adb:7:04: error: "T_Check" is not a static constant (RM 4.9(5))
bug.adb:7:04: error: instantiation error at a-conhel.ads:160
bug.adb:7:04: error: instantiation error at a-coinve.ads:407
bug.adb:7:04: error: non-static constant in preelaborated unit
bug.adb:7:04: error: instantiation error at a-conhel.ads:160
bug.adb:7:04: error: instantiation error at a-coinve.ads:407
bug.adb:7:04: error: "T_Check" is not a static constant (RM 4.9(5))
bug.adb:7:04: error: instantiation error at a-conhel.ads:166
bug.adb:7:04: error: instantiation error at a-coinve.ads:407
bug.adb:7:04: error: non-static constant in preelaborated unit
bug.adb:7:04: error: instantiation error at a-conhel.ads:166
bug.adb:7:04: error: instantiation error at a-coinve.ads:407
bug.adb:7:04: error: "T_Check" is not a static constant (RM 4.9(5))
gprbuild: *** compilation phase failed
I look into the reported lines and indeed I see things that don’t seem to be static, but I don’t think this is intended; besides it working in the other cases I mentioned which doesn’t make sense to me.
So, legit or not?