From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Indefinite_Holders: bug or misunderstanding? Date: Wed, 31 Jan 2018 13:06:36 +0100 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 31 Jan 2018 12:06:37 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="2f20b8b97fafce3f66bd673d6463738f"; logging-data="22092"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19fzC3M4Rxlf2pxgTJIFNE5" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Content-Language: en-US X-Mozilla-News-Host: news://news.eternal-september.org:119 Cancel-Lock: sha1:Wck8svUle3yyoUZDh9fqNFs2ueQ= Xref: reader02.eternal-september.org comp.lang.ada:50224 Date: 2018-01-31T13:06:36+01:00 List-Id: 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.