From: Rod Kay <rodakay5@gmail.com>
Subject: Re: Did I find a (nearly-)gotcha here?
Date: Sat, 13 Nov 2021 19:53:57 +1100 [thread overview]
Message-ID: <smnuf8$s9h$1@dont-email.me> (raw)
In-Reply-To: <29091147-1b81-4a3b-a646-c6a6d1ebe4ean@googlegroups.com>
On 13/11/21 18:46, reinert wrote:
>
> procedure test_a(ok : out Boolean) is
> begin
> if false then
> ok := true;
> end if;
> end test_a;
>
> I get the following output (using GNAT Community Edition):
>
> ok_a = FALSE
> ok_b = TRUE
>
> As far as I understand, this is correct.
> However, I think I remember that (some) older versions of the GNAT compiler gave a different result. Could others try? And does my program example reveal an unnecessary gotcha?
>
> reinert
>
Hi reinert,
The value of an 'out' only parameter needs to be explicitly set. The
initial value of the 'ok_a' variable will be discarded and then set to
the value of the 'ok' parameter within 'test_a' when the call completes.
Since 'ok' is not set in 'test_a' it's value is indeterminate (and
therefore erroneous).
I'd expect GNAT to issue a warning. Probably you need to add a flag
to GNAT to enable that warning. Perhaps try adding '-gnatwa'.
Regards.
next prev parent reply other threads:[~2021-11-13 8:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-13 7:46 Did I find a (nearly-)gotcha here? reinert
2021-11-13 8:52 ` Niklas Holsti
2021-11-13 8:53 ` Rod Kay [this message]
2021-11-14 8:25 ` G.B.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox