From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: GNAT 4.8 bug with subtype predicate
Date: Thu, 07 Mar 2013 03:11:55 +0100
Date: 2013-03-07T03:11:55+01:00 [thread overview]
Message-ID: <op.wtj0d51hule2fv@cardamome> (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
next reply other threads:[~2013-03-07 2:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 2:11 Yannick Duchêne (Hibou57) [this message]
2013-03-07 2:14 ` GNAT 4.8 bug with subtype predicate Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox