From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: GNAT doing macro‑expansion? (Pre/Post conditions)
Date: Wed, 24 Oct 2012 19:20:32 +0200
Date: 2012-10-24T19:20:32+02:00 [thread overview]
Message-ID: <op.wmo04iojule2fv@cardamome> (raw)
In-Reply-To: op.wmozh119ule2fv@cardamome
Le Wed, 24 Oct 2012 18:45:27 +0200, Yannick Duchêne (Hibou57)
<yannick_duchene@yahoo.fr> a écrit:
> Le Wed, 24 Oct 2012 18:40:58 +0200, Yannick Duchêne (Hibou57)
> <yannick_duchene@yahoo.fr> a écrit:
>
>> same snippet. Obviously, this does not stand for the reliable
> Read “does not stand for the real thing”.
>
>> type A_Type is mod 256;
>
> Sorry, forget to say about a second variation: replace the above with
> `type A_Type is new Positive;` and there will be no more error at
> runtime (the first error, that is, with the useless package body still
> there). That one is a lot weird.
>
More on that particular point. I you change `mod 256` into anything the
modulo is above 256, not necessarily a power of two, as this works with
`mod 257` two, then the bug disappears. The bug is there for any value
below and included, 256.
I suspected the element size, and indeed, that's not really the modulo,
but the size. Replace `type A_Type is mod 256;` with this, with an added
representation clause:
type A_Type is mod 256;
for A_Type'Size use 16;
The module is still 256, but now the size changed, and the bug is not
exposed.
--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
next prev parent reply other threads:[~2012-10-29 2:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-18 23:44 GNAT doing macro‑expansion for generics? (Pre/Post conditions) Yannick Duchêne (Hibou57)
2012-10-19 0:08 ` GNAT doing macro‑expansion? " Yannick Duchêne (Hibou57)
2012-10-24 16:40 ` Yannick Duchêne (Hibou57)
2012-10-24 16:45 ` Yannick Duchêne (Hibou57)
2012-10-24 17:20 ` Yannick Duchêne (Hibou57) [this message]
2012-10-24 18:16 ` GNAT doing macro-expansion? " Anh Vo
2012-10-24 18:43 ` Yannick Duchêne (Hibou57)
2012-10-24 18:53 ` Simon Wright
2012-10-24 19:02 ` Yannick Duchêne (Hibou57)
2012-10-24 21:43 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox