comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Efficient Matrix?
Date: Sat, 28 Dec 2002 16:07:37 GMT
Date: 2002-12-28T16:07:37+00:00	[thread overview]
Message-ID: <wccisxeqg8m.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: BA337210.16F9%yaldnifw@blueyonder.co.uk

Bill Findlay <yaldnifw@blueyonder.co.uk> 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



  parent reply	other threads:[~2002-12-28 16:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3e0b2a66_4@news.bluewin.ch>
2002-12-26 22:09 ` Efficient Matrix? Adrian Knoth
2002-12-27  0:23   ` Alvery Grazebrook
2002-12-27  9:53     ` Adrian Knoth
2002-12-27 16:58       ` Robert A Duff
2002-12-28  1:44         ` Nick Roberts
2002-12-28 13:00         ` Adrian Knoth
2002-12-28 15:21           ` Bill Findlay
2002-12-28 15:48             ` Adrian Knoth
2002-12-28 23:26               ` Adrian Knoth
2002-12-28 16:07             ` Robert A Duff [this message]
2002-12-28 17:25               ` Bill Findlay
2002-12-28 17:35                 ` Bill Findlay
2002-12-28 20:51                 ` Robert A Duff
2002-12-28 15:58           ` Robert A Duff
2002-12-28 17:19             ` Adrian Knoth
2002-12-28 19:16               ` James S. Rogers
2002-12-28 20:45               ` Robert A Duff
2002-12-28 22:07                 ` Adrian Knoth
2002-12-28 23:42                   ` Robert A Duff
2002-12-27 12:25 ` Gautier
replies disabled

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