From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Possible bug?
Date: Fri, 10 Jul 2015 17:33:15 -0500
Date: 2015-07-10T17:33:15-05:00 [thread overview]
Message-ID: <mnph7b$elv$1@loke.gir.dk> (raw)
In-Reply-To: mno5d2$s8e$1@dont-email.me
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1409 bytes --]
"J-P. Rosen" <rosen@adalog.fr> wrote in message
news:mno5d2$s8e$1@dont-email.me...
> Le 10/07/2015 11:46, Anatoly Chernyshev a écrit :
...
>> Even though it should abort the compilation with an error message.
>> No?
>>
> No. What happens is that it constructs an initialization aggregate whose
> bounds are (n_d, 2), and then raises Constraint_Error because the bounds
> of the initial value do not match those of the variable. That's exactly
> what the warning is telling you.
Right. More generally, "out of range" errors are always reported at runtime;
compilers often give a warning but they're not allowed to reject the
program. That's because perfectly sensible programs might contain an "out of
range" error in code that will never be executed, and one would be very
annoyed if the program was rejected.
Consider:
procedure Something (Mem : in Integer) is
Size : constant := 0;
begin
if Size /= 0 then
... Mem / Size ...
else
...
end if;
end Something;
If dividing by zero was a compile-time error, it wouldn't be possible to
divide by a constant whose value might be zero, even in code that's
protected by a pre-test. (Imagine that Size started out as 1 and then later
got changed to 0 during program maintenance.) That would be very annoying.
The same is true for aggregates, since they can be sized by constants.
Randy.
next prev parent reply other threads:[~2015-07-10 22:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 9:46 Possible bug? Anatoly Chernyshev
2015-07-10 10:06 ` J-P. Rosen
2015-07-10 22:33 ` Randy Brukardt [this message]
2015-07-11 0:29 ` Anatoly Chernyshev
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox