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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,13ab88b30e0f779d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-28 08:08:02 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!news-out.visi.com!hermes.visi.com!uunet!ash.uu.net!world!news From: Robert A Duff Subject: Re: Efficient Matrix? User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Sat, 28 Dec 2002 16:07:37 GMT Content-Type: text/plain; charset=us-ascii References: <3e0b2a66_4@news.bluewin.ch> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:32361 Date: 2002-12-28T16:07:37+00:00 List-Id: Bill Findlay writes: > I get good results as follows, with GNAT 5.00w for MacOS X. ^^^^ You misspelled "bad". ;-) > ----------------------------------------------------------- > with Ada.Text_IO; use Ada.Text_IO; > > procedure bla is > > type unconstrained_type is > array (Positive range <>, Positive range <>) of Boolean; > for unconstrained_type'Component_Size use 1; > pragma Pack (unconstrained_type); > > subtype constrained_type is unconstrained_type (1 .. 10000, 1 .. 5000); > type constrained_type_ptr is access constrained_type; > > A : constrained_type_ptr := new constrained_type; > > begin > Put_Line (Integer'Image (constrained_type'Component_Size)); > Put_Line (Integer'Image (unconstrained_type'Component_Size)); > Put_Line (Integer'Image (constrained_type'Size)); > Put_Line (Integer'Image (A.all'Size)); > end bla; > ---------------------------------------------------------------- > % ./bla > 1 > 8 > 50000000 > 50000000 That makes no sense. How can the 'Component_Size differ between subtypes of the same type? And how can the compiler accept the "for unconstrained_type'Component_Size use 1;", and then return unconstrained_type'Component_Size use = 8? I suspect that if you add: type Unconstrained_Type_Ptr is access Unconstrained_Type; B: Unconstrained_Type_Ptr := new Unconstrained_Type(1..10_000, 1..5000); then B.all'Size will be 50_000_000, implying that Unconstrained_Type'Component_Size really is 1, but the attribute is returning the wrong answer. If that's not true, then I'm very confused about what this compiler is up to. Note that the above is equivalent to: B: Unconstrained_Type_Ptr := new Constrained_Type; - Bob