comp.lang.ada
 help / color / mirror / Atom feed
* GNAT 4.8 bug with subtype predicate
@ 2013-03-07  2:11 Yannick Duchêne (Hibou57)
  2013-03-07  2:14 ` Yannick Duchêne (Hibou57)
  0 siblings, 1 reply; 2+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2013-03-07  2:11 UTC (permalink / raw)


Just out of curiosity, tell me what you get if you try this in a package  
specification:


     type T is range 1 .. 100
        with Dynamic_Predicate => T not in 10 .. 15;

     function F (I : T) return Positive
        is (Positive'Val (T'Pos (I)));


Do you get an error from GNAT complaining about “invalid use of subtype  
mark in expression or call” on the line holding the predicate?

That's what I get with GNAT from GCC 4.8.

The error disappears if I change `F` into:


     function F (I : T) return Positive
        is (Positive (I));


But that may not be allowed, if say T is a range, and the function returns  
Character (the direct conversion is not allowed, and requires 'Val/'Pos).

The error also disappears if I only have this in the public part


     function F (I : T) return Positive;


…then have this in the private part:


     function F (I : T) return Positive
        is (Positive'Val (T'Pos (I)));


-- 
“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



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: GNAT 4.8 bug with subtype predicate
  2013-03-07  2:11 GNAT 4.8 bug with subtype predicate Yannick Duchêne (Hibou57)
@ 2013-03-07  2:14 ` Yannick Duchêne (Hibou57)
  0 siblings, 0 replies; 2+ messages in thread
From: Yannick Duchêne (Hibou57) @ 2013-03-07  2:14 UTC (permalink / raw)


Le Thu, 07 Mar 2013 03:11:55 +0100, Yannick Duchêne (Hibou57)  
<yannick_duchene@yahoo.fr> a écrit:
> The error also disappears if I only have this in the public part
>
>
>      function F (I : T) return Positive;
>
>
> …then have this in the private part:
>
>
>      function F (I : T) return Positive
>         is (Positive'Val (T'Pos (I)));

Forget to say that may not be OK neither, if `F` is intended to be defined  
in the public part of the package spec'


-- 
“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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-03-07  2:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-07  2:11 GNAT 4.8 bug with subtype predicate Yannick Duchêne (Hibou57)
2013-03-07  2:14 ` Yannick Duchêne (Hibou57)

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