From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Indefinite_Holders: bug or misunderstanding?
Date: Wed, 31 Jan 2018 13:06:36 +0100
Date: 2018-01-31T13:06:36+01:00 [thread overview]
Message-ID: <p4sbgd$lic$1@dont-email.me> (raw)
I have used the Indefinite_Holders sometimes to make definite types from
classwide ones, or variant records without defaults. However this sample
case doesn't work with an array (with GNAT 2017 or GCC 7.2.0) and I'm
unsure wether it should:
---8<---
with Ada.Containers.Indefinite_Holders;
procedure Test_Holder is
package Inner is
type Str (<>) is private;
private
type Str is array (Positive range <>) of Character;
-- type Str (Len : Natural) is record
-- S : String (1 .. Len);
-- end record;
end Inner;
package Str_Holders is new Ada.Containers.Indefinite_Holders
(Inner.Str, Inner."=");
begin
null;
end Test_Holder;
---8<---
The commented alternate Str type does compile fine. The error I'm
getting for the uncommented one is:
$ gnatmake test_holder.adb
gcc -c test_holder.adb
test_holder.adb:19:04: instantiation error at a-coinho.adb:337
test_holder.adb:19:04: invalid constraint: type has no discriminant
test_holder.adb:19:04: instantiation error at a-coinho.adb:337
test_holder.adb:19:04: unconstrained subtype not allowed (need
initialization)
test_holder.adb:19:04: provide initial value or explicit array bounds
test_holder.adb:19:04: instantiation error at a-coinho.adb:337
test_holder.adb:19:04: expected private type "Str" defined at line 7
test_holder.adb:19:04: found type "Str" defined at line 11
gnatmake: "test_holder.adb" compilation error
Something obvious I'm missing?
Thanks,
Alex.
next reply other threads:[~2018-01-31 12:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-31 12:06 Alejandro R. Mosteo [this message]
2018-01-31 22:31 ` Indefinite_Holders: bug or misunderstanding? Shark8
2018-02-01 0:31 ` Randy Brukardt
2018-02-01 15:53 ` Alejandro R. Mosteo
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox