comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: CONSTRAINT_ERROR - why?
Date: Sun, 15 Dec 2002 18:20:53 GMT
Date: 2002-12-15T18:20:53+00:00	[thread overview]
Message-ID: <3DFCC831.2040103@acm.org> (raw)
In-Reply-To: 3DFC8B43.68D99D1C@t-online.de

Alfred Hilscher wrote:
> 
> I tried, but - it does not compile: "non-static expression used in
> number declaration". So it's _not_ a static expression and will generate
> code which will be executed during runtime.
> 
> I discussed the "why is 'size not static?" about half a year ago in cla
> (when I tried to declare a "type a is array (1..(x'size/8)) of
> character").

Another gotcha. At least is got me.

type X is mod 2 ** 8;

Z : constant := X'Size / 8;

is fine, but

type X is mod 2 ** 8;

type Y is record
    A : X;
end record;

Z : constant := Y'Size / 8;

isn't. This is one of those cases where the compiler has the information 
and could determine the value at compile time, but the language doesn't 
allow it. 'Size is static when the prefix is a static subtype, but only 
scalar and string subtypes can be static.

GNAT 3.14p seems to have an error here, as it flags 'Size of static 
string subtypes as non-static.

-- 
Jeff Carter
"I'm a lumberjack and I'm OK."
Monty Python's Flying Circus




  reply	other threads:[~2002-12-15 18:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-14 18:28 CONSTRAINT_ERROR - why? Alfred Hilscher
2002-12-14 18:45 ` James S. Rogers
2002-12-14 19:15   ` Robert A Duff
2002-12-14 19:20     ` James S. Rogers
2002-12-14 19:42     ` Alfred Hilscher
2002-12-16  2:39       ` AG
2002-12-14 19:20   ` Alfred Hilscher
2002-12-14 20:58     ` Dennis Lee Bieber
2002-12-15 13:45       ` Alfred Hilscher
2002-12-15 19:04         ` Robert A Duff
2002-12-16  1:12         ` Dennis Lee Bieber
2002-12-16  2:20           ` Jeffrey Carter
2002-12-16 18:48             ` Alfred Hilscher
2002-12-16 19:53               ` James S. Rogers
2002-12-17 18:20                 ` Alfred Hilscher
2002-12-17 19:29                   ` Robert A Duff
2002-12-17 21:05                     ` Dennis Lee Bieber
2002-12-18 18:36                     ` Alfred Hilscher
2002-12-18 18:51                       ` Robert A Duff
2002-12-18 21:45                         ` Randy Brukardt
2002-12-19 16:49                           ` Robert Spooner
2002-12-19 20:57                             ` Randy Brukardt
2002-12-14 20:19 ` Jeffrey Carter
2002-12-14 22:26   ` Alfred Hilscher
2002-12-15  0:49     ` Dennis Lee Bieber
2002-12-15  2:18     ` Jeffrey Carter
2002-12-15 18:23       ` Jeffrey Carter
2002-12-15 14:01   ` Alfred Hilscher
2002-12-15 18:20     ` Jeffrey Carter [this message]
2002-12-15 19:00       ` Alfred Hilscher
2002-12-16  1:16         ` Dennis Lee Bieber
2002-12-16 18:50           ` Alfred Hilscher
2002-12-17  2:17             ` Dennis Lee Bieber
2002-12-17 18:21               ` Alfred Hilscher
     [not found]                 ` <26tuvu4ekeigls0bnd2okavrdhfu0tir4a@4ax.com>
2002-12-18 18:47                   ` Alfred Hilscher
replies disabled

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