From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Misleading Compiler Warning
Date: Sun, 02 Feb 2003 19:03:53 GMT
Date: 2003-02-02T19:03:53+00:00 [thread overview]
Message-ID: <3E3D6BDC.1010501@acm.org> (raw)
In-Reply-To: d37844cb.0302020658.44064e1e@posting.google.com
Volkert wrote:
> pack.adc:9:03: warning: in instantiation at Gen.adc:4
> pack.adc:9:03: warning: value not in range of type "Standard.Integer"
> pack.adc:9:03: warning: "Constraint_Error" will be raised at run time
This is an unusual warning. However, I think some warning is a good
idea; see below.
>
> generic
> type S is private;
> package Gen is
>
> generic
> type T is range <>;
> package Inner_Gen is
> procedure Do_It;
> end Inner_Gen;
>
> end Gen;
>
> ---
>
> package body Gen is
>
> package body Inner_Gen is
> type B is array(T) of Boolean;
> pragma Pack(B);
> type C is array (0 .. 100) of B;
>
> procedure Do_It is
> O : C;
> begin
> O(1)(0) := False;
^ Here you assume that 0 is a value of the formal type T
> end;
>
> end;
>
> end Gen;
There is no guarantee that zero is a value of the actual type used for
the formal type T; a (sub)type with a 'First of one is very likely.
While the warning you got is not very good, some sort of warning seems
in order here.
--
Jeff Carter
"I've got to stay here, but there's no reason
why you folks shouldn't go out into the lobby
until this thing blows over."
Horse Feathers
next prev parent reply other threads:[~2003-02-02 19:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-02 14:58 Misleading Compiler Warning Volkert
2003-02-02 19:03 ` Jeffrey Carter [this message]
2003-02-03 6:04 ` Volkert
2003-02-03 16:54 ` Jeffrey Carter
2003-02-03 6:45 ` Simon Wright
2003-02-09 3:14 ` Robert I. Eachus
2003-02-09 15:31 ` Volkert
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox