comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: GNAT bug with assertions
Date: Mon, 13 Aug 2018 16:54:26 +0100
Date: 2018-08-13T16:54:26+01:00	[thread overview]
Message-ID: <lytvnymfd9.fsf@pushface.org> (raw)
In-Reply-To: ly36viocs0.fsf@pushface.org

Simon Wright <simon@pushface.org> writes:

> AdaMagica <christ-usch.grein@t-online.de> writes:
>
>> Am Sonntag, 12. August 2018 20:51:51 UTC+2 schrieb Simon Wright:
>>> AdaMagica writes:
>>>
>>> > Thank you all for your time to think about this.
>>> >
>>> > I'll send it in to AdaCore. Hopefully it will be correted next year
>>> > in the public version.
>>>
>>> This is a somewhat artificial error, isn't it?
>>>
>>>    function Maybe (X : Priv) return Subt;
>>>    ...
>>>    function Maybe (X : Priv) return Subt is (X);
>>>    ...
>>>    X := Maybe (C);   -- C is -1
>>>
>>> works as we would have expected.
>>
>> What is it that you expect here? What type is X? I didn't try with
>> GNAT, but I would expect Maybe (C) to raise Assertion_Error
>> independently of X.
>
> Oh come on! these are additions to the example that *you* posted upthread.

Oops.

X is of type Subt.

It can get quite misleading to use expression functions when trying to
use the debugger to work out where an exception is raised.

Given

   function Maybe (X : Priv) return Subt is
   begin
      return X;
   end Maybe;

called as

   S : Subt := Maybe (-);
   
Maybe happily returns -1 and leaves it up to the assignment to raise the
necessary exception.

And if the assignment is

   P : Priv := Maybe (-1);

no exception is raised.

  reply	other threads:[~2018-08-13 15:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-10 10:29 GNAT bug with assertions AdaMagica
2018-08-10 14:23 ` Anh Vo
2018-08-10 15:16 ` Jacob Sparre Andersen
2018-08-10 16:16   ` Simon Wright
2018-08-10 20:42     ` Randy Brukardt
2018-08-12 18:35       ` AdaMagica
2018-08-12 18:51         ` Simon Wright
2018-08-13  9:03           ` AdaMagica
2018-08-13  9:07             ` Simon Wright
2018-08-13 15:54               ` Simon Wright [this message]
2018-08-13 16:55                 ` Simon Wright
2018-08-14  2:37                 ` AdaMagica
replies disabled

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