comp.lang.ada
 help / color / mirror / Atom feed
* Indefinite_Holders: bug or misunderstanding?
@ 2018-01-31 12:06 Alejandro R. Mosteo
  2018-01-31 22:31 ` Shark8
  0 siblings, 1 reply; 4+ messages in thread
From: Alejandro R. Mosteo @ 2018-01-31 12:06 UTC (permalink / 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-01 15:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31 12:06 Indefinite_Holders: bug or misunderstanding? Alejandro R. Mosteo
2018-01-31 22:31 ` Shark8
2018-02-01  0:31   ` Randy Brukardt
2018-02-01 15:53     ` Alejandro R. Mosteo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox